dear sir ,
i want to pass null vaue but i can not pass null value please help me.
//balance quantity calculate in database use data set display in txtbalance.text database data type decimal1(8,2) string balanceQty txtbalance.text; // txtIssue.text client input and database data type decimal1(8,2) String IssueQty txtIssue.text;
// txtTransfer.text client input and database data type decimal1(8,2) String TransferQty txtTransfer.text;
//1.but i need frist time check balanceQty <IssueQty if result true then insert value IssueQty in database.and TransferQty ignore or null value insert in database. // and result false then lebel message show quantity exceeds. //1st condition code result ok. but 2nd condition not work at time.but separate time do the work.
//2.and again 2nd time txtIssue.text empty or null not input in client .client input to TransferQty . then check balanceQty <TransferQty //if result true then insert value TransferQtyin database.and IssueQty ignore or null value insert in database. // and result false then lebel message show quantity exceeds.
here code
//1.but i need frist time check balanceQty <IssueQty if result true then insert value IssueQty in database.and TransferQty ignore or null value insert in database.
// and result false then lebel message show quantity exceeds.
//1st condition code result ok. but 2nd condition not work at time.but separate time do the work.
///1st condition code here,
int IssueQty = 0;
int TQty = 0;
string tQty = txtTranstQty.Text;
int.TryParse(tQty, out TQty);
//if (txtIssueQty.Text != "")
//{
string issueQty = txtIssueQty.Text;
string x = txtBlanceQty.Text;
int.TryParse(issueQty, out IssueQty);
// cmd.Parameters.AddWithValue("@Issue_Qty", IssueQty > 0 ? IssueQty : (object)DBNull.Value);
if (decimal.Parse(x) < decimal.Parse(issueQty))
{
lblmsg.Text = " ";
lblExceeds.Text = "Quantiy Exceeds";
lblExceeds.Visible = true;
lblExceeds.ForeColor = System.Drawing.Color.Red;
/*Pass value to your store procedure as variable value or nullable value*/
}
else
{
// cmd.Parameters.AddWithValue("@Issue_Qty", txtIssueQty.Text);
cmd.Parameters.AddWithValue("@Issue_Qty", IssueQty > 0 ? IssueQty : (object)DBNull.Value);
cmd.Parameters.AddWithValue("@Transfer_Qty", TQty > 0 ? TQty : (object)DBNull.Value);
lblExceeds.Text = "";
}
//2.and again 2nd time txtIssue.text empty or null not input in client .client input to TransferQty . then check balanceQty <TransferQty
//if result true then insert value TransferQtyin database.and IssueQty ignore or null value insert in database.
// and result false then lebel message show quantity exceeds.
//2nd condition code here,
int TQty1 = 0;
int IssueQty1 = 0;
string issueQty1 = txtIssueQty.Text;
//string x = txtBlanceQty.Text;
int.TryParse(issueQty1, out IssueQty1);
// if (txtTranstQty.Text != "")
// {
string tQty1 = txtTranstQty.Text;
string x1 = txtBlanceQty.Text;
int.TryParse(tQty1, out TQty1);
if (decimal.Parse(x1) < decimal.Parse(tQty1))
{
lblmsg.Text = " ";
lblExceeds.Text = "Quantiy Exceeds";
lblExceeds.Visible = true;
lblExceeds.ForeColor = System.Drawing.Color.Red;
/*Pass value to your store procedure as variable value or nullable value*/
}
else
{
cmd.Parameters.AddWithValue("@Transfer_Qty", TQty1 > 0 ? TQty1 : (object)DBNull.Value);
lblExceeds.Text = "";
cmd.Parameters.AddWithValue("@Issue_Qty", IssueQty1 < 0 ? IssueQty1 : (object)DBNull.Value);
}