SqlCommand cmd = new SqlCommand("sp_sales_details", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@sd_id", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(id2) ? DBNull.Value : (object)id2;
cmd.Parameters.AddWithValue("@bill_no", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(bill_no) ? DBNull.Value : (object)bill_no;
cmd.Parameters.AddWithValue("@itemcode", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(itm_code) ? DBNull.Value : (object)itm_code;
cmd.Parameters.AddWithValue("@item", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(item) ? DBNull.Value : (object)item;
cmd.Parameters.AddWithValue("@unit", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(unitprice) ? DBNull.Value : (object)unitprice;
cmd.Parameters.AddWithValue("@qty", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(qty1) ? DBNull.Value : (object)qty1;
cmd.Parameters.AddWithValue("@amount", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(amt) ? DBNull.Value : (object)amt;
cmd.Parameters.AddWithValue("@date", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(date) ? DBNull.Value : (object)date;
cmd.Parameters.AddWithValue("@time", SqlDbType.Time).Value = string.IsNullOrWhiteSpace(time) ? DBNull.Value : (object)time;
cmd.Parameters.AddWithValue("@sales_id", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(sales_id) ? DBNull.Value : (object)sales_id;
cmd.Parameters.AddWithValue("@employee_id", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(txtCmboSelCaptain.SelectedValue.ToString()) ? DBNull.Value : (object)txtCmboSelCaptain.SelectedValue.ToString();
cmd.Parameters.AddWithValue("@shift", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(shift.ToString()) ? DBNull.Value : (object)shift.ToString();
cmd.Parameters.AddWithValue("@tables", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(tables) ? DBNull.Value : (object)tables;
cmd.Parameters.AddWithValue("@chair", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(chair) ? DBNull.Value : (object)chair;
cmd.Parameters.AddWithValue("@remarks", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(remarks) ? DBNull.Value : (object)remarks;
cmd.Parameters.AddWithValue("@unit_type", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(unit_type) ? DBNull.Value : (object)unit_type;
cmd.Parameters.AddWithValue("@ser_tax", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(ser_tax) ? DBNull.Value : (object)ser_tax;
cmd.Parameters.AddWithValue("@var_tax", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(vat_tax) ? DBNull.Value : (object)vat_tax;
cmd.Parameters.AddWithValue("@service", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(service) ? DBNull.Value : (object)service;
cmd.Parameters.AddWithValue("@vat", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(vat) ? DBNull.Value : (object)vat;
cmd.Parameters.AddWithValue("@total_amount", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(total) ? DBNull.Value : (object)total;
cmd.Parameters.AddWithValue("@cat", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(cat) ? DBNull.Value : (object)cat;
cmd.Parameters.AddWithValue("@sales_type", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(sales_type) ? DBNull.Value : (object)sales_type;
cmd.Parameters.AddWithValue("@captain_id", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(txtCmboSelCaptain.SelectedValue.ToString()) ? DBNull.Value : (object)txtCmboSelCaptain.SelectedValue.ToString();
cmd.Parameters.AddWithValue("@kot_no", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(kot.ToString()) ? DBNull.Value : (object)kot.ToString();
cmd.Parameters.AddWithValue("@kot_status", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(kot_status) ? DBNull.Value : (object)kot_status;
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Inserted Successfully", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);
What I have tried:
SqlCommand cmd = new SqlCommand("sp_sales_details", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@sd_id", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(id2) ? DBNull.Value : (object)id2;
cmd.Parameters.AddWithValue("@bill_no", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(bill_no) ? DBNull.Value : (object)bill_no;
cmd.Parameters.AddWithValue("@itemcode", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(itm_code) ? DBNull.Value : (object)itm_code;
cmd.Parameters.AddWithValue("@item", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(item) ? DBNull.Value : (object)item;
cmd.Parameters.AddWithValue("@unit", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(unitprice) ? DBNull.Value : (object)unitprice;
cmd.Parameters.AddWithValue("@qty", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(qty1) ? DBNull.Value : (object)qty1;
cmd.Parameters.AddWithValue("@amount", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(amt) ? DBNull.Value : (object)amt;
cmd.Parameters.AddWithValue("@date", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(date) ? DBNull.Value : (object)date;
cmd.Parameters.AddWithValue("@time", SqlDbType.Time).Value = string.IsNullOrWhiteSpace(time) ? DBNull.Value : (object)time;
cmd.Parameters.AddWithValue("@sales_id", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(sales_id) ? DBNull.Value : (object)sales_id;
cmd.Parameters.AddWithValue("@employee_id", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(txtCmboSelCaptain.SelectedValue.ToString()) ? DBNull.Value : (object)txtCmboSelCaptain.SelectedValue.ToString();
cmd.Parameters.AddWithValue("@shift", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(shift.ToString()) ? DBNull.Value : (object)shift.ToString();
cmd.Parameters.AddWithValue("@tables", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(tables) ? DBNull.Value : (object)tables;
cmd.Parameters.AddWithValue("@chair", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(chair) ? DBNull.Value : (object)chair;
cmd.Parameters.AddWithValue("@remarks", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(remarks) ? DBNull.Value : (object)remarks;
cmd.Parameters.AddWithValue("@unit_type", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(unit_type) ? DBNull.Value : (object)unit_type;
cmd.Parameters.AddWithValue("@ser_tax", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(ser_tax) ? DBNull.Value : (object)ser_tax;
cmd.Parameters.AddWithValue("@var_tax", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(vat_tax) ? DBNull.Value : (object)vat_tax;
cmd.Parameters.AddWithValue("@service", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(service) ? DBNull.Value : (object)service;
cmd.Parameters.AddWithValue("@vat", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(vat) ? DBNull.Value : (object)vat;
cmd.Parameters.AddWithValue("@total_amount", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(total) ? DBNull.Value : (object)total;
cmd.Parameters.AddWithValue("@cat", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(cat) ? DBNull.Value : (object)cat;
cmd.Parameters.AddWithValue("@sales_type", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(sales_type) ? DBNull.Value : (object)sales_type;
cmd.Parameters.AddWithValue("@captain_id", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(txtCmboSelCaptain.SelectedValue.ToString()) ? DBNull.Value : (object)txtCmboSelCaptain.SelectedValue.ToString();
cmd.Parameters.AddWithValue("@kot_no", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(kot.ToString()) ? DBNull.Value : (object)kot.ToString();
cmd.Parameters.AddWithValue("@kot_status", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(kot_status) ? DBNull.Value : (object)kot_status;
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Inserted Successfully", "Fill Field", MessageBoxButton.OK, MessageBoxImage.Information);