private void btn_Add_Itm_Click(object sender, EventArgs e) { try { //Check if the Details is Validated if (FormValidate_Details()) { //Check if the item already esixt in the grid view. Hashtable Params = new Hashtable(); Params.Add("@Qty_Unit", Convert.ToInt32(txt_Qty_Big_Unit.Text)); Params.Add("@Qty_Smallest_Unit", Convert.ToInt32(txt_Qty_Small_Unit.Text)); Params.Add("@Itm_ID", Convert.ToInt32(cbo_Itm_Name.SelectedValue)); outputParams QtyParam = new outputParams() { ParamName = "Qty", ParamValue = 0 }; int Qty = Convert.ToInt32(DataAccessLayer.RunStoredProcedure("PRO_Itm_Qty", Params, QtyParam)); int RowSelected = CheckItemExistance(Convert.ToInt32(cbo_Itm_Name.SelectedValue)); if (RowSelected >= 0) { //if true Update the Qty FillTheRow(RowSelected, Qty); } else { //false Add New Row //DataRow row = DT.Rows[0]; //txt_Itm_No.ToString() //dgv_Itm_Returned.Rows.Add(); //dgv_Itm_Returned.DataSource = DataAccessLayer.GetDataTable(); int y = dgv_Itm_Returned.Rows.Count; z = y - 1; dgv_Itm_Returned.Rows[z].Cells[0].Value = cbo_Itm_Name.SelectedValue.ToString(); dgv_Itm_Returned.Rows[z].Cells[1].Value = cbo_Itm_Name.SelectedText; //dgv_Itm_Returned.Rows[z].Cells[3].Value = txt_Qty_Big_Unit.Text; //dgv_Itm_Returned.Rows[z].Cells[4].Value = txt_Qty_Small_Unit.Text; dgv_Itm_Returned.Rows[z].Cells[2].Value = Qty.ToString(); dgv_Itm_Returned.Rows[z].Cells[3].Value = txt_Price.Text; dgv_Itm_Returned.Rows[z].Cells[4].Value = txt_Add_No.Text; FillTheRow(z, Qty); dgv_Itm_Returned.Rows.Add(); } } } catch (Exception exp) { MessageBox.Show(exp.Message); } }
private void btn_Add_Itm_Click(object sender, EventArgs e) { try { //Check if the Details is Validated if (FormValidate_Details()) { //Check if the item already esixt in the grid view. Hashtable Params = new Hashtable(); Params.Add("@Qty_Unit", Convert.ToInt32(txt_Qty_Big_Unit.Text)); Params.Add("@Qty_Smallest_Unit", Convert.ToInt32(txt_Qty_Small_Unit.Text)); Params.Add("@Itm_ID", Convert.ToInt32(cbo_Itm_Name.SelectedValue)); outputParams QtyParam = new outputParams() { ParamName = "Qty", ParamValue = 0 }; int Qty = Convert.ToInt32(DataAccessLayer.RunStoredProcedure("PRO_Itm_Qty", Params, QtyParam)); int RowSelected = CheckItemExistance(Convert.ToInt32(cbo_Itm_Name.SelectedValue)); if (RowSelected >= 0) { //if true Update the Qty FillTheRow(RowSelected - 1, Qty); } else { //false Add New Row dgv_Itm_Returned_Edit.Rows.Add(); FillTheRow(dgv_Itm_Returned_Edit.Rows.Count - 2, Qty); } } } catch (Exception exp) { MessageBox.Show(exp.Message); } }
internal static object RunStoredProcedure(string StoredProcedureName, Hashtable Params, outputParams Out) { object returnValue = null; try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand("PRO_Itm_Qty", connection); command.CommandType = CommandType.StoredProcedure; foreach (DictionaryEntry item in Params) { command.Parameters.AddWithValue(item.Key.ToString(), item.Value); } command.Parameters.AddWithValue(Out.ParamName, Out.ParamValue); command.Parameters[Out.ParamName].Direction = ParameterDirection.Output; connection.Open(); command.ExecuteNonQuery(); return(command.Parameters[Out.ParamName].Value); } //Display The Selected Items. } catch (Exception exp) { MessageBox.Show(exp.Message); } return(returnValue); }