private void savebutton_Click(object sender, EventArgs e) { //if (id == "") //{ // id = "1"; // txtsrno.Text = id; //} //else //{ // int t = Convert.ToInt32(id); // int t1 = t + 1; // txtsrno.Text = t1.ToString(); //} counter = 0; if (counter == 0) { string insertquery = "insert into orderdetails values('" + txtcustomercode.Text + "','" + dtpdate.Text + "','" + txttotalammount.Text + "')"; int insertrows = d.saveDetails(insertquery); DataGridViewRowCollection rowcollection = gridsalesorder.Rows; List <string> show = new List <string>(); for (int a = 0; a < rowcollection.Count; a++) { DataGridViewRow currentrow = rowcollection[a]; DataGridViewCellCollection cellcollection = currentrow.Cells; string txtitemcode = cellcollection[0].Value.ToString(); string txtProductName = cellcollection[1].Value.ToString(); string txtRate = cellcollection[2].Value.ToString(); string txtQuantity = cellcollection[3].Value.ToString(); string txtAmount = cellcollection[4].Value.ToString(); string Orderid = txtsrno.Text; string query = "insert into customerorderdescriptions Values('" + txtsrno.Text + "','" + txtitemcode + "','" + txtRate + "','" + txtQuantity + "','" + txtAmount + "')"; show.Add(query); } int inserirow1 = d.saveDetails(show); if (inserirow1 > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } int id = Convert.ToInt32(txtsrno.Text); id = id + 1; txtsrno.Text = id.ToString(); makeblank(); } }
private void btnSave_Click(object sender, EventArgs e) { int index = item.Items.IndexOf(txtGroupName.Text.ToUpper()); if (index >= 0) { MessageBox.Show("GroupName allready exists"); } else { string insertQuery = "insert into dbo.ItemGroup values ('" + txtGroupID.Text + "','" + txtGroupName.Text.ToUpper() + "','" + txtGroupDesc.Text + "')"; int insertedRecord = dbMainClass.saveDetails(insertQuery); if (insertedRecord > 0) { if (item.Items.Contains("Add New Group")) { item.Items.Remove("Add New Group"); item.Items.Insert(0, "Select A Group"); } GroupList.Add(txtGroupID.Text); item.Items.Add(txtGroupName.Text); item.SelectedIndex = item.Items.IndexOf(txtGroupName.Text); this.Close(); } else { MessageBox.Show("Details Can Not Saved"); } } }
private void button5_Click(object sender, EventArgs e) { if (txtRefNo.Text == "") { string delivary = "select Delivaryid from salesOrderDelivery"; DataTable dt3 = d.getDetailByQuery(delivary); string delivaryid = ""; foreach (DataRow dr in dt3.Rows) { delivaryid = dr[0].ToString(); } int del = Convert.ToInt32(delivaryid); int deli = del + 1; string order = "select orderid from orderdetails "; DataTable d1 = d.getDetailByQuery(order); string id = ""; foreach (DataRow dr in d1.Rows) { id = dr[0].ToString(); } if (id == "") { id = "1"; string insertquery = "insert into orderdetails values('" + txtCustcode.Text + "','" + dtpdate.Text + "','" + txttotalammount.Text + "')"; int insertrows = d.saveDetails(insertquery); if (insertrows > 0) { DataGridViewRowCollection rowcollection = gridsalesinvoice.Rows; List <string> show = new List <string>(); for (int a = 0; a < rowcollection.Count; a++) { DataGridViewRow currentrow = rowcollection[a]; DataGridViewCellCollection cellcollection = currentrow.Cells; string txtitemcode = cellcollection[0].Value.ToString(); string txtProductName = cellcollection[1].Value.ToString(); string txtRate = cellcollection[2].Value.ToString(); string txtQuantity = cellcollection[3].Value.ToString(); string txtAmount = cellcollection[4].Value.ToString(); string Orderid = id; string query = "insert into customerorderdescriptions Values('" + Orderid + "','" + txtitemcode + "','" + txtRate + "','" + txtQuantity + "','" + txtAmount + "')"; show.Add(query); } int inserirow1 = d.saveDetails(show); if (inserirow1 > 0) { string salesdelivary = "Insert into salesOrderDelivery values('" + id + "','true','" + dtpdate.Text + "')"; int insertrow = d.saveDetails(salesdelivary); string invoice = "Insert into salesinvoice values('" + deli + "','" + id + "','" + dtpdate.Text + "')"; int insertrow1 = d.saveDetails(invoice); if (insertrow1 > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } } } } else { int id1 = Convert.ToInt32(id); int id2 = id1 + 1; string Orde = id2.ToString(); string insertquery1 = "insert into orderdetails values('" + txtCustcode.Text + "','" + dtpdate.Text + "','" + txttotalammount.Text + "')"; int insertrows1 = d.saveDetails(insertquery1); if (insertrows1 > 0) { DataGridViewRowCollection rowcollection1 = gridsalesinvoice.Rows; List <string> show1 = new List <string>(); for (int a = 0; a < rowcollection1.Count; a++) { DataGridViewRow currentrow = rowcollection1[a]; DataGridViewCellCollection cellcollection = currentrow.Cells; string txtitemcode = cellcollection[0].Value.ToString(); string txtProductName = cellcollection[1].Value.ToString(); string txtRate = cellcollection[2].Value.ToString(); string txtQuantity = cellcollection[3].Value.ToString(); string txtAmount = cellcollection[4].Value.ToString(); string Orderid = id2.ToString(); string query = "insert into customerorderdescriptions Values('" + Orderid + "','" + txtitemcode + "','" + txtRate + "','" + txtQuantity + "','" + txtAmount + "')"; show1.Add(query); } int inserirow2 = d.saveDetails(show1); if (inserirow2 > 0) { string salesdelivary = "Insert into salesOrderDelivery values('" + id2.ToString() + "','true','" + dtpdate.Text + "')"; int insertrow = d.saveDetails(salesdelivary); string invoice = "Insert into salesinvoice values('" + deli + "','" + id2.ToString() + "','" + dtpdate.Text + "')"; int insertrow2 = d.saveDetails(invoice); if (insertrow2 > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } } } } } if (txtRefNo.Text != "") { string delivary = "select Delivaryid from salesOrderDelivery"; DataTable dt3 = d.getDetailByQuery(delivary); string delivaryid = txtRefNo.Text; //foreach (DataRow dr in dt3.Rows) //{ // delivaryid = dr[0].ToString(); //} //int del = Convert.ToInt32(delivaryid); //int deli = del + 1; string order = "select Orderid from salesOrderDelivery where Delivaryid ='" + txtRefNo.Text + "' "; DataTable d1 = d.getDetailByQuery(order); string id = ""; foreach (DataRow dr in d1.Rows) { id = dr[0].ToString(); } string update = "update orderdetails set totalammount='" + txttotalammount.Text + "'where Orderid='" + id + "'"; int c = d.saveDetails(update); string deletequrri1 = "delete customerorderdescriptions where OrderId='" + id + "'"; DataTable dt1 = d.getDetailByQuery(deletequrri1); string insertquery = "insert into orderdetails values('" + txtCustcode.Text + "','" + dtpdate.Text + "','" + txttotalammount.Text + "')"; int insertrows = d.saveDetails(insertquery); if (insertrows > 0) { DataGridViewRowCollection rowcollection = gridsalesinvoice.Rows; List <string> show = new List <string>(); for (int a = 0; a < rowcollection.Count; a++) { DataGridViewRow currentrow = rowcollection[a]; DataGridViewCellCollection cellcollection = currentrow.Cells; string txtitemcode = cellcollection[0].Value.ToString(); string txtProductName = cellcollection[1].Value.ToString(); string txtRate = cellcollection[2].Value.ToString(); string txtQuantity = cellcollection[3].Value.ToString(); string txtAmount = cellcollection[4].Value.ToString(); // string Orderid = id; string query = "insert into customerorderdescriptions Values('" + id + "','" + txtitemcode + "','" + txtRate + "','" + txtQuantity + "','" + txtAmount + "')"; show.Add(query); } int inserirow1 = d.saveDetails(show); if (inserirow1 > 0) { string salesdelivary = "Update salesOrderDelivery set DeliveryDate='" + dtpdate.Text + "' where delivaryid='" + delivaryid + "'"; int insertrow = d.saveDetails(salesdelivary); string invoic = "Insert into salesinvoice values('" + txtRefNo.Text + "','" + id + "','" + dtpdate.Text + "')"; int insertrow1 = d.saveDetails(invoic); if (insertrow1 > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } } } } int id3 = Convert.ToInt32(txtSrNo.Text); int id4 = id3 + 1; txtSrNo.Text = id4.ToString(); Form5 s = new Form5(id3.ToString()); s.Show(); makeblank(); }
private void butSaveButton_Click(object sender, EventArgs e) { if (txtRefNo.Text == "") { string order = "select orderid from orderdetails "; DataTable d1 = d.getDetailByQuery(order); string id = ""; foreach (DataRow dr in d1.Rows) { id = dr[0].ToString(); } if (id == "") { id = "1"; string insertquery = "insert into orderdetails values('" + txtcustomercode.Text + "','" + dtpDate.Text + "','" + txtTotalAmmount.Text + "')"; int insertrows = d.saveDetails(insertquery); if (insertrows > 0) { DataGridViewRowCollection rowcollection = gridsalesdelivary.Rows; List <string> show = new List <string>(); for (int a = 0; a < rowcollection.Count; a++) { DataGridViewRow currentrow = rowcollection[a]; DataGridViewCellCollection cellcollection = currentrow.Cells; string txtitemcode = cellcollection[0].Value.ToString(); string txtProductName = cellcollection[1].Value.ToString(); string txtRate = cellcollection[2].Value.ToString(); string txtQuantity = cellcollection[3].Value.ToString(); string txtAmount = cellcollection[5].Value.ToString(); string Orderid = id; string query = "insert into customerorderdescriptions Values('" + Orderid + "','" + txtitemcode + "','" + txtRate + "','" + txtQuantity + "','" + txtAmount + "')"; // int insertrow = d.saveDetails(query); show.Add(query); } int inserirow1 = d.saveDetails(show); if (inserirow1 > 0) { string salesdelivary = "Insert into salesOrderDelivery values('" + id + "','true','" + dtpDate.Text + "')"; int insert = d.saveDetails(salesdelivary); if (insert > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } } } } else { int id1 = Convert.ToInt32(id); int id2 = id1 + 1; string Orde = id2.ToString(); string insertquery = "insert into orderdetails values('" + txtcustomercode.Text + "','" + dtpDate.Text + "','" + txtTotalAmmount.Text + "')"; int insertrows = d.saveDetails(insertquery); if (insertrows > 0) { DataGridViewRowCollection rowcollection = gridsalesdelivary.Rows; List <string> show = new List <string>(); for (int a = 0; a < rowcollection.Count; a++) { DataGridViewRow currentrow = rowcollection[a]; DataGridViewCellCollection cellcollection = currentrow.Cells; string txtitemcode = cellcollection[0].Value.ToString(); string txtProductName = cellcollection[1].Value.ToString(); string txtRate = cellcollection[2].Value.ToString(); string txtQuantity = cellcollection[3].Value.ToString(); string txtAmount = cellcollection[5].Value.ToString(); //string orderid = txtSrNo.Text; string query = "insert into customerorderdescriptions Values('" + Orde + "','" + txtitemcode + "','" + txtRate + "','" + txtQuantity + "','" + txtAmount + "')"; //int insertrow = d.saveDetails(query); show.Add(query); } int inserirow1 = d.saveDetails(show); if (inserirow1 > 0) { string salesdelivary = "Insert into salesOrderDelivery values('" + Orde + "','true','" + dtpDate.Text + "')"; int insert = d.saveDetails(salesdelivary); if (insert > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } } } } makeblank(); } if (txtRefNo.Text != "") { string deletequrri1 = "delete customerorderdescriptions where OrderId='" + txtRefNo.Text + "'"; DataTable dt1 = d.getDetailByQuery(deletequrri1); counter = 0; if (counter == 0) { DataGridViewRowCollection rowcollection = gridsalesdelivary.Rows; List <string> show = new List <string>(); for (int a = 0; a < rowcollection.Count; a++) { DataGridViewRow currentrow = rowcollection[a]; DataGridViewCellCollection cellcollection = currentrow.Cells; string txtitemcode = cellcollection[0].Value.ToString(); // string txtproductname = cellcollection[1].Value.ToString(); string txtRate = cellcollection[2].Value.ToString(); string txtQuantity = cellcollection[4].Value.ToString(); string txtAmount = cellcollection[5].Value.ToString(); string Orderid = txtRefNo.Text; string query = "insert into customerorderdescriptions Values('" + Orderid + "','" + txtitemcode + "','" + txtRate + "','" + txtQuantity + "','" + txtAmount + "')"; show.Add(query); } int inserirow1 = d.saveDetails(show); if (inserirow1 > 0) { string insertquery = "insert into salesOrderDelivery values('" + txtRefNo.Text + "','true','" + dtpDate.Text + "')"; int insert = d.saveDetails(insertquery); if (insert > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } } } } makeblank(); int value = Convert.ToInt32(txtSrNo.Text); int value1 = value + 1; txtSrNo.Text = value1.ToString(); }
private void button5_Click(object sender, EventArgs e) { if (txtRef.Text == "") { string order = "select orderId from VendorOrderDetails"; DataTable dt1 = dbMainClass.getDetailByQuery(order); string id2 = ""; foreach (DataRow dr in dt1.Rows) { id2 = dr[0].ToString(); } string OrderID = ""; if (id2 == "") { id2 = "1"; OrderID = id2; string insertqurry = "insert into VendorOrderDetails values('" + textVendercod.Text + "','" + txtdate.Text + "','" + txttotalAmount.Text + "')"; int insertedRows = dbMainClass.saveDetails(insertqurry); if (insertedRows > 0) { DataGridViewRowCollection RowCollection = dataGridView1.Rows; List <string> sf = new List <string>(); for (int a = 0; a < RowCollection.Count; a++) { DataGridViewRow currentRow = RowCollection[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCod = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanit = cellCollection[3].Value.ToString(); string txtAmoun = cellCollection[5].Value.ToString(); string Query = "insert into VendorOrderDesc Values('" + OrderID + "','" + txtItemCod + "','" + txtRate + "','" + txtQuanit + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf.Add(Query); } int insertedRows1 = dbMainClass.saveDetails(sf); if (insertedRows1 > 0) { string deleteQurry = "delete VendorOrderDesc where Orderid='" + OrderID + "'"; DataTable dt = dbMainClass.getDetailByQuery(deleteQurry); DataGridViewRowCollection RowCollection1 = dataGridView1.Rows; List <string> sf1 = new List <string>(); for (int a = 0; a < RowCollection1.Count; a++) { DataGridViewRow currentRow = RowCollection1[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCode = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanity = cellCollection[4].Value.ToString(); string txtAmoun = cellCollection[5].Value.ToString(); //string OrderID1 = OrderID; string Query = "insert into VendorOrderDesc Values('" + OrderID + "','" + txtItemCode + "','" + txtRate + "','" + txtQuanity + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf1.Add(Query); } int insertedRows2 = dbMainClass.saveDetails(sf1); if (insertedRows2 > 0) { string insertQurry = "insert into CustomerOrderDelivery Values('" + OrderID + "','true','" + txtdate.Text + "')"; int insertedRows3 = dbMainClass.saveDetails(insertQurry); if (insertedRows3 > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } // MessageBox.Show("Details Saved Successfully"); //} //else //{ // MessageBox.Show("Details Not Saved Successfully"); //} } } } else { int id3 = Convert.ToInt32(id2); int id4 = id3 + 1; OrderID = id4.ToString(); string insertqurry1 = "insert into VendorOrderDetails values('" + textVendercod.Text + "','" + txtdate.Text + "','" + txttotalAmount.Text + "')"; int insertedRows1 = dbMainClass.saveDetails(insertqurry1); if (insertedRows1 > 0) { DataGridViewRowCollection RowCollection = dataGridView1.Rows; List <string> sf = new List <string>(); for (int a = 0; a < RowCollection.Count; a++) { DataGridViewRow currentRow = RowCollection[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCod = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanit = cellCollection[3].Value.ToString(); string txtAmoun = cellCollection[5].Value.ToString(); string Query = "insert into VendorOrderDesc Values('" + OrderID + "','" + txtItemCod + "','" + txtRate + "','" + txtQuanit + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf.Add(Query); } int insertedRows2 = dbMainClass.saveDetails(sf); if (insertedRows2 > 0) { string deleteQurry = "delete VendorOrderDesc where Orderid='" + OrderID + "'"; DataTable dt = dbMainClass.getDetailByQuery(deleteQurry); DataGridViewRowCollection RowCollection2 = dataGridView1.Rows; List <string> sf1 = new List <string>(); for (int a = 0; a < RowCollection.Count; a++) { DataGridViewRow currentRow = RowCollection2[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCode = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanity = cellCollection[4].Value.ToString(); string txtAmoun = cellCollection[5].Value.ToString(); // string OrderID = id4.ToString(); ; string Query = "insert into VendorOrderDesc Values('" + OrderID + "','" + txtItemCode + "','" + txtRate + "','" + txtQuanity + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf1.Add(Query); } int insertedRows4 = dbMainClass.saveDetails(sf1); if (insertedRows4 > 0) { string insertQurry = "insert into CustomerOrderDelivery Values('" + OrderID + "','true','" + txtdate.Text + "')"; int insertedRows5 = dbMainClass.saveDetails(insertQurry); if (insertedRows5 > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } // MessageBox.Show("Details Saved Successfully"); //} //else //{ // MessageBox.Show("Details Not Saved Successfully"); //} } } } } else if (txtRef.Text != "") { string deleteQurry = "delete VendorOrderDesc where Orderid='" + txtRef.Text + "'"; DataTable dt = dbMainClass.getDetailByQuery(deleteQurry); //dataGridView1.DataSource = ""; counter = 0; if (counter == 0) { DataGridViewRowCollection RowCollection = dataGridView1.Rows; List <string> sf1 = new List <string>(); for (int a = 0; a < RowCollection.Count; a++) { DataGridViewRow currentRow = RowCollection[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCode = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanity = cellCollection[4].Value.ToString(); string txtAmoun = cellCollection[5].Value.ToString(); string OrderID = txtRef.Text; string Query = "insert into VendorOrderDesc Values('" + OrderID + "','" + txtItemCode + "','" + txtRate + "','" + txtQuanity + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf1.Add(Query); } int insertedRows1 = dbMainClass.saveDetails(sf1); if (insertedRows1 > 0) { string insertQurry = "insert into CustomerOrderDelivery Values('" + txtRef.Text + "','true','" + txtdate.Text + "')"; int insertedRows2 = dbMainClass.saveDetails(insertQurry); if (insertedRows2 > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } } } makeBlank(); int id = Convert.ToInt32(txtSrNo.Text); int id1 = id + 1; txtSrNo.Text = id1.ToString(); }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtAddress.Text)) { MessageBox.Show("please enter your address"); } else { if (string.IsNullOrEmpty(txtTXTPHONE.Text) && string.IsNullOrEmpty(txtMOBILE.Text)) { MessageBox.Show("please enter your phone no and mo no"); } //else //{ // if (!this.txtEMAILADDRESS.Text.Contains('@') || !this.txtEMAILADDRESS.Text.Contains('.')) // { // MessageBox.Show("Please select your correct email address"); // } // else // { // if (!this.txtWEBSITE.Text.Contains('@') || !this.txtWEBSITE.Text.Contains('.') || !this.txtWEBSITE.Text.Contains('/')) // { // MessageBox.Show("plese select your corect website"); // } else { if (updateCounter == 0) { string saveCommand1 = "insert into CustomerDetails values ('" + txtCustCode.Text + "','" + txtName.Text + "','" + txtCompnyName.Text + "','" + txtAddress.Text + "','" + txtCity.Text + "','" + txtState.Text + "','" + txtZIP.Text + "','" + txtCustCountry.Text + "','" + txtEMAILADDRESS.Text + "','" + txtWEBSITE.Text + "','" + txtTXTPHONE.Text + "', '" + txtMOBILE.Text + "','" + txtFAX.Text + "','" + txtDESCRIPTION.Text + "','" + txtPanno.Text + "','" + txttanno.Text + "','" + txtothers.Text + "')"; string saveCommand2 = "insert into CustomerAccountDetails values ('" + txtCustCode.Text + "','" + txtCustCode.Text + "','" + txtOPENINGBALANCE.Text + "','" + txtCURRENTBALANCE.Text + "')"; int insertedRows = dbMainClass.saveDetails(saveCommand1, saveCommand2); if (insertedRows > 0) { btnList.Enabled = true; txtName.Focus(); MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } else if (updateCounter == 1) { string updateCommand1 = "update CustomerDetails set Custid='" + txtCustCode.Text + "', CustAddress='" + txtAddress.Text + "',CustPhone='" + txtTXTPHONE.Text + "', CustMobile='" + txtMOBILE.Text + "',PanNO='" + txtPanno.Text + "',TanNo='" + txttanno.Text + "',Others='" + txtothers.Text + "', CustName='" + txtName.Text + "', CustCompName= '" + txtCompnyName.Text + "',CustCity='" + txtCity.Text + "',CustState='" + txtState.Text + "',CustZip='" + txtZIP.Text + "',CustCountry='" + txtCustCountry.Text + "',CustEmail='" + txtEMAILADDRESS.Text + "',CustWebAddress='" + txtWEBSITE.Text + "',CustFax='" + txtFAX.Text + "',CustDesc='" + txtDESCRIPTION.Text + "' where Custid='" + txtCustCode.Text + "'"; string updateCommand2 = "update CustomerAccountDetails set CustOpeningBalance='" + txtOPENINGBALANCE.Text + "',CustCurrentBalance='" + txtCURRENTBALANCE.Text + "' where Custid='" + txtCustCode.Text + "'"; int updatedRows = dbMainClass.updateDetails(updateCommand1, updateCommand2); if (updatedRows > 0) { txtName.Focus(); MessageBox.Show("Details Updated Successfully"); } else { MessageBox.Show("Details Can not updated"); } updateCounter = 0; } makeblank(); blank1(); string Id = dbMainClass.getUniqueID("CUSTOMER"); txtCustCode.Text = Id; } } }
private void buttSave_Click(object sender, EventArgs e) { string ChaqueDate = varible.bankDate; string BankName = varible.bankname; string ChaqueNo = varible.chaqueNo; if (txtRefNo.Text == "") { if (radioBottCash.Checked) { string insertqurry = "insert into WithoutRefrencePament values('" + txtvendorId.Text + "','" + txttotalAmount.Text + "','" + txtPayAmount.Text + "','" + txtRemaning.Text + "','" + txtpayDate.Text + "')"; int insert1 = dbMainClass.saveDetails(insertqurry); if (insert1 > 0) { int bal2 = vendid1(); string updat = "update VendorAccountDetails set vCurrentBalance='" + bal2.ToString() + "' where venderId='" + txtvendorId.Text + "'"; int insertrow = dbMainClass.saveDetails(updat); if (insertrow > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } } else if (ChaqueReado.Checked) { string insertqurry = "insert into WithoutRefrencePament values('" + txtvendorId.Text + "','" + txttotalAmount.Text + "','" + txtPayAmount.Text + "','" + txtRemaning.Text + "','" + txtpayDate.Text + "'"; int insert1 = dbMainClass.saveDetails(insertqurry); if (insert1 > 0) { string insertqurry1 = "insert into ChequePement Values('" + txtSrNo.Text + "','" + ChaqueDate + "','" + BankName + "','" + ChaqueNo + "','" + txtPayAmount.Text + "')"; int insertrow = dbMainClass.saveDetails(insertqurry1); if (insertrow > 0) { int bal2 = vendid1(); string updat = "update VendorAccountDetails set vCurrentBalance='" + bal2.ToString() + "' where venderId='" + txtvendorId.Text + "'"; int insertrow1 = dbMainClass.saveDetails(updat); if (insertrow1 > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } } } } if (txtRefNo.Text != "") { if (radioBottCash.Checked) { string insertqurrey = "insert into VendorPayment Values('" + txtRefNo.Text + "','" + txttotalAmount.Text + "','" + txtPayAmount.Text + "','" + txtRemaning.Text + "','Cash','" + txtpayDate.Text + "')"; int insert = dbMainClass.saveDetails(insertqurrey); if (insert > 0) { int bal2 = vendid(); string updat = "update VendorAccountDetails set vCurrentBalance='" + bal2.ToString() + "' where venderId='" + txtvendorId.Text + "'"; int insertrow = dbMainClass.saveDetails(updat); if (insertrow > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } } else if (ChaqueReado.Checked) { string insertqurrey = "insert into VendorPayment Values('" + txtRefNo.Text + "','" + txttotalAmount.Text + "','" + txtPayAmount.Text + "','" + txtRemaning.Text + "','Chaque','" + txtpayDate.Text + "')"; int insert = dbMainClass.saveDetails(insertqurrey); if (insert > 0) { string insertqurry = "insert into ChequePement Values('" + txtSrNo.Text + "','" + ChaqueDate + "','" + BankName + "','" + ChaqueNo + "','" + txtPayAmount.Text + "')"; int insertrow = dbMainClass.saveDetails(insertqurry); if (insertrow > 0) { int bal2 = vendid(); string updat = "update VendorAccountDetails set vCurrentBalance='" + bal2.ToString() + "' where venderId='" + txtvendorId.Text + "'"; int insertrow1 = dbMainClass.saveDetails(updat); if (insertrow1 > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } } } } makeBlank(); makeBlank1(); int id = Convert.ToInt32(txtSrNo.Text); int id1 = id + 1; txtSrNo.Text = id1.ToString(); }
private void btnItemSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtItemProductName.Text)) { MessageBox.Show("please select your itemname"); } else { if (string.IsNullOrEmpty(txtItemCompName.Text)) { MessageBox.Show("please select your compnay name"); } else { if (string.IsNullOrEmpty(txtItemDesc.Text)) { MessageBox.Show("please select your description"); } else { if (string.IsNullOrEmpty(cmbItemItemGroup.Text)) { MessageBox.Show("please select your item group"); } else { if (string.IsNullOrEmpty(cmbItemUnit.Text)) { MessageBox.Show("plese select your unit"); } else { if (string.IsNullOrEmpty(txtItemPrice.Text)) { MessageBox.Show("please select your itemprice"); } else { if (string.IsNullOrEmpty(txtItemSalesPrice.Text)) { MessageBox.Show("please select your sales price"); } else { if (string.IsNullOrEmpty(txtItemMrp.Text)) { MessageBox.Show("please select your mrp"); } else { if (string.IsNullOrEmpty(txtItemMargin.Text)) { MessageBox.Show("please select your margin"); } else { if (string.IsNullOrEmpty(txtItemOpeningQuant.Text)) { MessageBox.Show("please select your opening quantity"); } if (updatecounter == 0) { if (cmbItemItemGroup.SelectedIndex != 0 && cmbItemUnit.SelectedIndex != 0) { string UnitId = UnitList[cmbItemUnit.SelectedIndex - 1]; string GroupId = GroupList[cmbItemItemGroup.SelectedIndex - 1]; string saveCommand1 = "insert into ItemDetails values ('" + txtItemProductCode.Text + "','" + txtItemProductName.Text + "','" + txtItemCompName.Text + "','" + txtItemDesc.Text + "','" + GroupId + "','" + UnitId + "')"; string saveCommand2 = "insert into ItemPriceDetail values ('" + txtItemProductCode.Text + "','" + txtItemPrice.Text + "','" + txtItemSalesPrice.Text + "','" + txtItemMrp.Text + "','" + txtItemMargin.Text + "')"; string saveCommand3 = "insert into ItemQuantityDetail values ('" + txtItemProductCode.Text + "','" + txtItemOpeningQuant.Text + "','" + txtItemRemaningQuant.Text + "')"; int insertedRows = dbMainClass.saveDetails(saveCommand1, saveCommand2, saveCommand3); if (insertedRows > 0) { //btnList.Enabled = true; txtItemProductName.Focus(); MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } } else if (updatecounter == 1) { string saveCommand1 = "update ItemDetails set itemId='" + txtItemProductCode.Text + "',itemName='" + txtItemProductName.Text + "',itemCompName='" + txtItemCompName.Text + "',itemDesc='" + txtItemDesc.Text + "',groupid='" + cmbItemItemGroup.Text + "',Unitid='" + cmbItemUnit.Text + "'where itemId='" + txtItemProductCode.Text + "'"; string saveCommand2 = "update ItemPriceDetail set purChasePrice='" + txtItemPrice.Text + "', SalesPrice='" + txtItemSalesPrice.Text + "', MrpPrice='" + txtItemMrp.Text + "',Margin='" + txtItemMargin.Text + "'where itemId='" + txtItemProductCode.Text + "'"; string saveCommand3 = "update ItemQuantityDetail set OpeningQuantity='" + txtItemOpeningQuant.Text + "',CurrentQuantity='" + txtItemRemaningQuant.Text + "' where itemId='" + txtItemProductCode.Text + "'"; int insertedRows = dbMainClass.saveDetails(saveCommand1, saveCommand2, saveCommand3); if (insertedRows > 0) { txtItemProductName.Focus(); MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } makeBlank(); string Id = dbMainClass.getUniqueID("ItemDetails"); txtItemProductCode.Text = Id; } } } } } } } } } }
private void buttSave_Click(object sender, EventArgs e) { if (txtRef.Text == "") { string order = "select Deliveryidfrom CustomerOrderDelivery"; DataTable dt1 = dbMainClass.getDetailByQuery(order); string id2 = ""; string id5 = ""; foreach (DataRow dr in dt1.Rows) { id5 = dr[0].ToString(); } string order1 = "select Orderid from VendorOrderDetails"; DataTable dt4 = dbMainClass.getDetailByQuery(order1); foreach (DataRow dr in dt4.Rows) { id2 = dr[0].ToString(); } string OrderID = ""; if (id2 == "") { id2 = "1"; OrderID = id2; string insertqurry = "insert into VendorOrderDetails values('" + txtVendorId.Text + "','" + dtpInvoiceDate.Text + "','" + txtTotalAmount.Text + "')"; int insertedRows = dbMainClass.saveDetails(insertqurry); //if (insertedRows > 0) //{ DataGridViewRowCollection RowCollection = dataGridView1.Rows; List <string> sf = new List <string>(); for (int a = 0; a < RowCollection.Count; a++) { DataGridViewRow currentRow = RowCollection[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCod = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanit = cellCollection[3].Value.ToString(); string txtAmoun = cellCollection[5].Value.ToString(); string Query = "insert into VendorOrderDesc Values('" + OrderID + "','" + txtItemCod + "','" + txtRate + "','" + txtQuanit + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf.Add(Query); } int insertedRows1 = dbMainClass.saveDetails(sf); if (insertedRows1 > 0) { if (id5 == "") { string deleteQurry = "delete VendorOrderDesc where Orderid='" + id2 + "'"; DataTable dt = dbMainClass.getDetailByQuery(deleteQurry); //dataGridView1.DataSource = ""; DataGridViewRowCollection RowCollection2 = dataGridView1.Rows; List <string> sf1 = new List <string>(); for (int a = 0; a < RowCollection2.Count; a++) { DataGridViewRow currentRow = RowCollection2[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCode = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanity = cellCollection[4].Value.ToString(); string txtAmoun = cellCollection[5].Value.ToString(); string OrderID1 = id2; string Query = "insert into VendorOrderDesc Values('" + OrderID1 + "','" + txtItemCode + "','" + txtRate + "','" + txtQuanity + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf1.Add(Query); } int insertedRows4 = dbMainClass.saveDetails(sf1); if (insertedRows4 > 0) { string insertQurry = "insert into CustomerOrderDelivery Values('" + txtRef.Text + "','true','" + dtpInvoiceDate.Text + "')"; int insertedRows2 = dbMainClass.saveDetails(insertQurry); if (insertedRows2 > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } } } } else { int id3 = Convert.ToInt32(id2); int id4 = id3 + 1; OrderID = id4.ToString(); string insertqurry1 = "insert into VendorOrderDetails values('" + txtVendorId.Text + "','" + dtpInvoiceDate.Text + "','" + txtTotalAmount.Text + "')"; int insertedRows1 = dbMainClass.saveDetails(insertqurry1); //if (insertedRows1 > 0) //{ DataGridViewRowCollection RowCollection = dataGridView1.Rows; List <string> sf = new List <string>(); for (int a = 0; a < RowCollection.Count; a++) { DataGridViewRow currentRow = RowCollection[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCod = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanit = cellCollection[3].Value.ToString(); string txtAmoun = cellCollection[4].Value.ToString(); string Query = "insert into VendorOrderDesc Values('" + OrderID + "','" + txtItemCod + "','" + txtRate + "','" + txtQuanit + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf.Add(Query); } int insertedRows2 = dbMainClass.saveDetails(sf); if (insertedRows2 > 0) { string deleteQurry1 = "delete VendorOrderDesc where Orderid='" + OrderID + "'"; DataTable dt5 = dbMainClass.getDetailByQuery(deleteQurry1); //dataGridView1.DataSource = ""; DataGridViewRowCollection RowCollection1 = dataGridView1.Rows; List <string> sf2 = new List <string>(); for (int a = 0; a < RowCollection1.Count; a++) { DataGridViewRow currentRow = RowCollection1[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCode = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanity = cellCollection[3].Value.ToString(); string txtAmoun = cellCollection[4].Value.ToString(); string OrderID2 = OrderID; string Query = "insert into VendorOrderDesc Values('" + OrderID2 + "','" + txtItemCode + "','" + txtRate + "','" + txtQuanity + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf2.Add(Query); } int insertedRows3 = dbMainClass.saveDetails(sf2); if (insertedRows3 > 0) { string insertQurry = "insert into CustomerOrderDelivery Values('" + OrderID + "','true','" + dtpInvoiceDate.Text + "')"; int insertedRows5 = dbMainClass.saveDetails(insertQurry); if (insertedRows5 > 0) { string select1 = "select * from CustomerOrderDelivery where Orderid='" + OrderID + "'"; DataTable dt2 = dbMainClass.getDetailByQuery(select1); if (dt2 != null && dt2.Rows != null && dt2.Rows.Count > 0) { DataRow dr1 = dt2.Rows[0]; string r = dr1[1].ToString(); string s = dr1[0].ToString(); string select = "select * from CustomerOrderDelivery where Deliveryid='" + s + "'"; DataTable dt = dbMainClass.getDetailByQuery(select); if (dt != null && dt.Rows != null && dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; string c = dr[0].ToString(); string Qurry1 = "insert into CustomerOrderInvoice Values('" + c + "','" + r + "','" + dtpInvoiceDate.Text + "')"; int insertedRows = dbMainClass.saveDetails(Qurry1); if (insertedRows > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } } // } } } } } int id = Convert.ToInt32(txtSrNo.Text); int id1 = id + 1; txtSrNo.Text = id1.ToString(); // F9.MdiParent = this; Form9 F9 = new Form9(id.ToString()); F9.Show(); makeBlank(); } if (txtRef.Text != "") { string select1 = "select * from CustomerOrderDelivery where Deliveryid='" + txtRef.Text + "'"; DataTable dt2 = dbMainClass.getDetailByQuery(select1); if (dt2 != null && dt2.Rows != null && dt2.Rows.Count > 0) { DataRow dr1 = dt2.Rows[0]; string r = dr1[1].ToString(); string deleteQurry = "delete VendorOrderDesc where Orderid='" + r + "'"; DataTable dt3 = dbMainClass.getDetailByQuery(deleteQurry); } counter = 0; if (counter == 0) { //string insertqurry = "insert into VendorOrderDetails values('" +txtVendorId.Text + "','" + txtdate.Text + "','" + txtTotalAmount.Text + "')"; //int insertedRows = dbMainClass.saveDetails(insertqurry); //if (insertedRows > 0) //{ // MessageBox.Show("Details Saved Successfully"); //} //else //{ // MessageBox.Show("Details Not Saved Successfully"); //} string select = "select * from CustomerOrderDelivery where Deliveryid='" + txtRef.Text + "'"; DataTable dt = dbMainClass.getDetailByQuery(select); if (dt != null && dt.Rows != null && dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; string c = dr[1].ToString(); DataGridViewRowCollection RowCollection4 = dataGridView1.Rows; List <string> sf4 = new List <string>(); for (int a = 0; a < RowCollection4.Count; a++) { DataGridViewRow currentRow = RowCollection4[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCode = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanity = cellCollection[3].Value.ToString(); string txtAmoun = cellCollection[4].Value.ToString(); string OrderID3 = c; string Query = "insert into VendorOrderDesc Values('" + OrderID3 + "','" + txtItemCode + "','" + txtRate + "','" + txtQuanity + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf4.Add(Query); } int insertedRows5 = dbMainClass.saveDetails(sf4); if (insertedRows5 > 0) { string Qurry1 = "insert into CustomerOrderInvoice Values('" + txtRef.Text + "','" + c + "','" + dtpInvoiceDate.Text + "')"; int insertedRows = dbMainClass.saveDetails(Qurry1); if (insertedRows > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } } } //} //F9.MdiParent = this; makeBlank(); int id = Convert.ToInt32(txtSrNo.Text); int id1 = id + 1; txtSrNo.Text = id1.ToString(); Form9 F9 = new Form9(id.ToString()); F9.Show(); } }
private void button5_Click(object sender, EventArgs e) { string Chaquedate = Value.Bankdate; string bankname = Value.Bankname; string chaqueno = Value.chaqueno; string chaqueammount = Value.chaqueammount; if (txtRefNo.Text == "") { if (radioButton1.Checked) { string insertquery = "Insert into vithautrefrancereceipt values('" + txtcustomerid.Text + "','" + txttotalammount.Text + "','" + txtpayammount.Text + "','" + dtpdate.Text + "')"; int insert = d.saveDetails(insertquery); string selectquery = "select CustCurrentBalance from CustomerAccountDetails where Custid='" + txtcustomerid.Text + "'"; DataTable dt = d.getDetailByQuery(selectquery); string id = ""; foreach (DataRow dr in dt.Rows) { id = dr[0].ToString(); } int id1 = Convert.ToInt32(id); int id2 = Convert.ToInt32(txtreamaining.Text); int id3 = id2; string update = "update CustomerAccountDetails set CustCurrentBalance='" + id3.ToString() + "' where Custid='" + txtcustomerid.Text + "'"; int c = d.saveDetails(update); if (c > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } } else if (radioButton2.Checked) { string insertquery1 = "Insert into vithautrefrancereceipt values('" + txtcustomerid.Text + "','" + txttotalammount.Text + "','" + txtpayammount.Text + "','" + txtreamaining.Text + "','" + dtpdate.Text + "')"; int insert2 = d.saveDetails(insertquery1); string selectquery = "select CustCurrentBalance from CustomerAccountDetails where Custid='" + txtcustomerid.Text + "'"; DataTable dt = d.getDetailByQuery(selectquery); string id = ""; foreach (DataRow dr in dt.Rows) { id = dr[0].ToString(); } int id1 = Convert.ToInt32(id); int id2 = Convert.ToInt32(txtreamaining.Text); int id3 = id2; string update = "update CustomerAccountDetails set CustCurrentBalance='" + id3.ToString() + "' where Custid='" + txtcustomerid.Text + "'"; int c = d.saveDetails(update); if (c > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } } } else if (txtRefNo.Text != "") { if (radioButton1.Checked) { string insertd = "insert into payment values('" + txtRefNo.Text + "','" + txttotalammount.Text + "','" + txtpayammount.Text + "','" + txtreamaining.Text + "','Cash','" + dtpdate.Text + "')"; int s2 = d.saveDetails(insertd); if (s2 > 0) { string selectquery = "select CustCurrentBalance from CustomerAccountDetails where Custid='" + txtcustomerid.Text + "'"; DataTable dt = d.getDetailByQuery(selectquery); string id = ""; foreach (DataRow dr in dt.Rows) { id = dr[0].ToString(); } int id1 = Convert.ToInt32(id); int id2 = Convert.ToInt32(txtreamaining.Text); int id3 = id1 + id2; string update = "update CustomerAccountDetails set CustCurrentBalance='" + id3.ToString() + "' where Custid='" + txtcustomerid.Text + "'"; int c = d.saveDetails(update); if (c > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } } } else if (radioButton2.Checked) { string insert3 = "insert into payment values('" + txtRefNo.Text + "','" + txttotalammount.Text + "','" + txtpayammount.Text + "','" + txtreamaining.Text + "','Chaque','" + dtpdate.Text + "')"; int s3 = d.saveDetails(insert3); if (s3 > 0) { string insert4 = "Insert into chaquedetail values('" + txtSrNo.Text + "','" + Chaquedate + "','" + bankname + "','" + chaqueno + "','" + chaqueammount + "')"; int insertrow = d.saveDetails(insert4); if (insertrow > 0) { string id = ""; string selectquery = "select CustCurrentBalance from CustomerAccountDetails where Custid='" + txtcustomerid.Text + "'"; DataTable dt = d.getDetailByQuery(selectquery); foreach (DataRow dr in dt.Rows) { id = dr[0].ToString(); } int id1 = Convert.ToInt32(id); int id2 = Convert.ToInt32(txtreamaining.Text); int id3 = id1 + id2; string update = "update CustomerAccountDetails set CustCurrentBalance='" + id3.ToString() + "'where Custid='" + txtcustomerid.Text + "'"; int c1 = d.saveDetails(update); if (c1 > 0) { MessageBox.Show("details save successfully"); } else { MessageBox.Show("details save not successfully"); } } } } } makeblank(); makeblank1(); }
/// <summary> /// To Save Details /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnVenderSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtVenderName.Text)) { MessageBox.Show("please Enter the name"); } else { if (string.IsNullOrEmpty(txtCompanyName.Text)) { MessageBox.Show("please Enter the Company name"); } else { if (string.IsNullOrEmpty(txtVenderAddress.Text)) { MessageBox.Show("please Enter the Address"); } else { //if (string.IsNullOrEmpty(txtVenderPhone.Text) && string.IsNullOrEmpty(txtVenderMobile.Text)) //{ // MessageBox.Show("please Enter the Mobile No. ya Phone No."); //} //else //{ // if (!this.txtVenderEmailAddress.Text.Contains('@') || !this.txtVenderEmailAddress.Text.Contains('.')) // { // MessageBox.Show("Please Enter the Correct Email Address"); // } // else // { //if (!this.txtVenderWebSite.Text.Contains('@') || !this.txtVenderWebSite.Text.Contains('.') || !this.txtVenderWebSite.Text.Contains("http://")) //{ // MessageBox.Show("Please Enter the Correct Web Site Address"); ////} //else //{ if (updateCounter == 0) { string saveCommand1 = "insert into VendorDetails values ('" + txtVenderCode.Text + "','" + txtVenderName.Text + "','" + txtCompanyName.Text + "','" + txtVenderAddress.Text + "','" + txtVenderCity.Text + "','" + txtVenderState.Text + "','" + txtVenderZip.Text + "','" + txtVenderCountry.Text + "','" + txtVenderEmailAddress.Text + "','" + txtVenderWebSite.Text + "','" + txtVenderPhone.Text + "', '" + txtVenderMobile.Text + "','" + txtVenderFax.Text + "','" + txtVenderDesc.Text + "','" + txtPanNo.Text + "','" + txtTinNo.Text + "','" + txtOther.Text + "')"; string saveCommand2 = "insert into VendorAccountDetails values ('" + txtVenderCode.Text + "','" + txtVenderCode.Text + "','" + txtVenderOpeningBal.Text + "','" + txtVenderCurrentBal.Text + "')"; int insertedRows = dbMainClass.saveDetails(saveCommand1, saveCommand2); if (insertedRows > 0) { btnVenderList.Enabled = true; MessageBox.Show("Details Saved Successfully"); txtVenderName.Focus(); } else { MessageBox.Show("Details Not Saved Successfully"); } } else if (updateCounter == 1) { string updateCommand1 = "update VendorDetails set vName='" + txtVenderName.Text + "', vCompName= '" + txtCompanyName.Text + "',vAddress='" + txtVenderAddress.Text + "',vCity='" + txtVenderCity.Text + "',vState='" + txtVenderState.Text + "',vZip='" + txtVenderZip.Text + "',vCountry='" + txtVenderCountry.Text + "',vEmail='" + txtVenderEmailAddress.Text + "',vWebAddress='" + txtVenderWebSite.Text + "',vPhone='" + txtVenderPhone.Text + "', vMobile='" + txtVenderMobile.Text + "',vFax='" + txtVenderFax.Text + "',vPanNo='" + txtPanNo.Text + "',vTinNo='" + txtTinNo.Text + "',vDesc='" + txtVenderDesc.Text + "',vOther='" + txtOther.Text + "' where venderid='" + txtVenderCode.Text + "'"; string updateCommand2 = "update VendorAccountDetails set vOpeningBalance='" + txtVenderOpeningBal.Text + "',vCurrentBalance='" + txtVenderCurrentBal.Text + "' where venderId='" + txtVenderCode.Text + "'"; int updatedRows = dbMainClass.updateDetails(updateCommand1, updateCommand2); if (updatedRows > 0) { txtVenderName.Focus(); MessageBox.Show("Details Updated Successfully"); } else { MessageBox.Show("Details Can not updated"); } updateCounter = 0; } makeBlank(); Enabled2(); string Id = dbMainClass.getUniqueID("VENDOR"); txtVenderCode.Text = Id; //} //} } } } }
private void btnSave_Click(object sender, EventArgs e) { DataGridViewRowCollection call = gridPurchaseOrder.Rows; for (int c = 0; c < call.Count; c++) { DataGridViewRow currentRow1 = call[c]; DataGridViewCellCollection cellCollection1 = currentRow1.Cells; string itid = cellCollection1[0].Value.ToString(); string que = cellCollection1[3].Value.ToString(); string qurry = "select CurrentQuantity from ItemQuantityDetail where ItemId='" + itid + "'"; DataTable dt = dbMainClass.getDetailByQuery(qurry); string id = ""; foreach (DataRow dr in dt.Rows) { id = dr["CurrentQuantity"].ToString(); } int curentQuntity = Convert.ToInt32(que); int cuentQuantity = Convert.ToInt32(id); int lastQuantity = cuentQuantity + curentQuntity; string id1 = lastQuantity.ToString(); string updateQurry = "update ItemQuantityDetail set CurrentQuantity='" + id1 + "'where ItemId='" + itid + "'"; int insertedRows2 = dbMainClass.saveDetails(updateQurry); } counter = 0; if (counter == 0) { string insertqurry = "insert into VendorOrderDetails values('" + txtVendorCode.Text + "','" + dtpDate.Text + "','" + txtTotalAmount.Text + "')"; int insertedRows = dbMainClass.saveDetails(insertqurry); if (insertedRows > 0) { DataGridViewRowCollection RowCollection = gridPurchaseOrder.Rows; List <string> sf = new List <string>(); for (int a = 0; a < RowCollection.Count; a++) { DataGridViewRow currentRow = RowCollection[a]; DataGridViewCellCollection cellCollection = currentRow.Cells; string txtItemCod = cellCollection[0].Value.ToString(); string txtRate = cellCollection[2].Value.ToString(); string txtQuanit = cellCollection[3].Value.ToString(); string txtAmoun = cellCollection[4].Value.ToString(); string OrderID = txtSrNo.Text; string Query = "insert into VendorOrderDesc Values('" + OrderID + "','" + txtItemCod + "','" + txtRate + "','" + txtQuanit + "','" + txtAmoun + "')"; //MessageBox.Show(Query); sf.Add(Query); } int insertedRows1 = dbMainClass.saveDetails(sf); if (insertedRows1 > 0) { MessageBox.Show("Details Saved Successfully"); } else { MessageBox.Show("Details Not Saved Successfully"); } } makeBlank(); int id2 = Convert.ToInt32(txtSrNo.Text); int id3 = id2 + 1; txtSrNo.Text = id3.ToString(); } }