private void button1_Click(object sender, EventArgs e) { if (txtValidation() == true) { string ans = (MessageBox.Show("Do you want to Continue Save", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Information)).ToString(); if (ans == "Yes") { try { int rows1 = Convert.ToInt32(dataGridView1.RowCount.ToString()) - 2; for (int i = 0; i <= rows1; i++) { string itemname1, barcode1, skucode1, mrp2; try { itemname1 = dataGridView1.Rows[i].Cells["itemname"].Value.ToString(); } catch { itemname1 = ""; } try { barcode1 = dataGridView1.Rows[i].Cells["barcode"].Value.ToString(); } catch { barcode1 = ""; } try { skucode1 = dataGridView1.Rows[i].Cells["skucode"].Value.ToString(); } catch { skucode1 = ""; } try { mrp2 = dataGridView1.Rows[i].Cells["mrp1"].Value.ToString(); } catch { mrp2 = ""; } string save1 = "INSERT INTO [MRP_for_Customer]([CustomerName],[ItemName],[SKUcode],[Barcode],[MRP],[EnterBy],[EnterDate],[company])VALUES" + "('" + comboBox1.Text + "','" + itemname1 + "','" + skucode1 + "','" + barcode1 + "','" + mrp2 + "','" + username + "','" + System.DateTime.Now.ToString("MM/dd/yyyy") + "','" + company + "')"; affect = ObjCon.affect(save1); } MessageBox.Show("Data Saved Successfully"); comboBox1.Text = ""; dataGridView1.Rows.Clear(); lblrows.Text = ""; } catch { } } } }
private void button1_Click(object sender, EventArgs e) { string ans = (MessageBox.Show("Do you want to Continue Save", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Information)).ToString(); if (ans == "Yes") { string conString = "Data Source=.;Initial Catalog=Neemali_Natural;User ID=sa;Password=preet@1234"; con = new SqlConnection(conString); con.Open(); SqlCommand cmd1 = new SqlCommand(); try { string gstno = txtgst_no.Text + textBox1.Text; if (chkimg == true) { if (assestype == "Yes") { dr.Close(); save = "update [Company_Master] set [Comp_display_name] = '" + compname.Text + "' , [Company_Address1] = '" + add1.Text + "' , [Company_Address2]='" + add2.Text + "' , " + "[Company_Address3] = '" + add3.Text + "' , [Bussiness_Line]='" + busline.Text + "' , [Pincode]= '" + pincode.Text + "' , [City] = '" + city.Text + "' , [State] ='" + txtState.Text + "' , " + "[Country]='" + country.Text + "' , [Phone_No]='" + phoneno.Text + "' , [FaxNo]='" + faxno.Text + "', [E_MailID]='" + email.Text + "' , [DateOfIncorp]='" + datofincorp.Value.ToString("MM/dd/yyyy") + "' , " + "[OwnerName1]='" + ownname1.Text + "' , [OwnerName2]='" + ownname2.Text + "' , [MobileNo1]='" + ownmob1.Text + "' ,[MobileNo2]='" + ownmob2.Text + "' ,[PANo]='" + panno.Text + "' , " + "[Jurisdication]='" + juris.Text + "' , [Company_sht_code]='" + txtShortCode.Text + "' , [LogoImage]=@ImageData , [GST_No]='" + gstno + "' , [CINno]='" + cin_no.Text + "' ," + "[Assese_type]='Yes',[Modify_by] = '" + username + "',[Modify_Date] = '" + System.DateTime.Now.ToString("MM/dd/yyyy") + "' where [Company_Name] = '" + compname.Text + "'"; SqlCommand SqlCom = new SqlCommand(save, con); byte[] imageData = ReadFile(image); SqlCom.Parameters.Add(new SqlParameter("@ImageData", (object)imageData)); SqlCom.ExecuteNonQuery(); } else { dr.Close(); save = "update [Company_Master] set [Comp_display_name] = '" + compname.Text + "' , [Company_Address1] = '" + add1.Text + "' , [Company_Address2]='" + add2.Text + "' , " + "[Company_Address3] = '" + add3.Text + "' , [Bussiness_Line]='" + busline.Text + "' , [Pincode]= '" + pincode.Text + "' , [City] = '" + city.Text + "' , [State] ='" + txtState.Text + "' , " + "[Country]='" + country.Text + "' , [Phone_No]='" + phoneno.Text + "' , [FaxNo]='" + faxno.Text + "' , [E_MailID]='" + email.Text + "' , [DateOfIncorp]='" + datofincorp.Text + "' , " + "[OwnerName1]='" + ownname1.Text + "' ,[OwnerName2]='" + ownname2.Text + "' , [MobileNo1]='" + ownmob1.Text + "' , [MobileNo2]='" + ownmob2.Text + "' , [PANo]='" + panno.Text + "' , " + "[Jurisdication]='" + juris.Text + "' , [Company_sht_code]='" + txtShortCode.Text + "' , [LogoImage]=@ImageData , [CINno]='" + cin_no.Text + "' , [Assese_type]='No' " + ",[Modify_by] = '" + username + "',[Modify_Date] = '" + System.DateTime.Now.ToString("MM/dd/yyyy") + "' where [Company_Name] = '" + compname.Text + "'"; SqlCommand SqlCom = new SqlCommand(save, con); byte[] imageData = ReadFile(image); SqlCom.Parameters.Add(new SqlParameter("@ImageData", (object)imageData)); SqlCom.ExecuteNonQuery(); } dr.Close(); string str = "select [Company_ID] from [Company_Master] where [Company_Name] = '" + compname.Text + "'"; dr = objCon.getData(str); if (dr.HasRows) { while (dr.Read()) { compid = dr[0].ToString(); } } dr.Close(); string save2 = "update [Bank_details] set [bank_name]='" + txt_bankname.Text + "' , [bank_branch]='" + txtbranch.Text + "',[account_name]='" + txt_ac_name.Text + "' , [account_no]='" + txt_ac_no.Text + "' ," + "[IFSC_code]='" + txtifsc_code.Text + "' , [MICR_code]='" + txtMicr_code.Text + "',[Modify_by] = '" + username + "',[Modify_Date] ='" + System.DateTime.Now.ToString("MM/dd/yyyy") + "' where [comp_id] = '" + compid + "'"; affect = objCon.affect(save2); } else { if (assestype == "Yes") { dr.Close(); save = "update [Company_Master] set [Comp_display_name] = '" + compname.Text + "' ,[Company_Address1] = '" + add1.Text + "' , [Company_Address2]='" + add2.Text + "' , " + "[Company_Address3] = '" + add3.Text + "' ,[Bussiness_Line]='" + busline.Text + "' , [Pincode]= '" + pincode.Text + "' , [City] = '" + city.Text + "' ,[State] ='" + txtState.Text + "' , " + "[Country]='" + country.Text + "' , [Phone_No]='" + phoneno.Text + "',[FaxNo]='" + faxno.Text + "' , [E_MailID]='" + email.Text + "' , [DateOfIncorp]='" + datofincorp.Text + "' , " + "[OwnerName1]='" + ownname1.Text + "' , [OwnerName2]='" + ownname2.Text + "' ,[MobileNo1]='" + ownmob1.Text + "' , [MobileNo2]='" + ownmob2.Text + "' , [PANo]='" + panno.Text + "' , " + "[Jurisdication]='" + juris.Text + "' ,[Company_sht_code]='" + txtShortCode.Text + "',[GST_No]='" + gstno + "' , [CINno]='" + cin_no.Text + "' ,[LogoImage] = null, " + "[Assese_type]='Yes',[Modify_by] = '" + username + "',[Modify_Date] = '" + System.DateTime.Now.ToString("MM/dd/yyyy") + "' where [Company_Name] = '" + compname.Text + "'"; affect = objCon.affect(save); } else { dr.Close(); save = "update [Company_Master] set [Comp_display_name] = '" + compname.Text + "' , [Company_Address1] = '" + add1.Text + "' ,[Company_Address2]='" + add2.Text + "' , " + "[Company_Address3] = '" + add3.Text + "' , [Bussiness_Line]='" + busline.Text + "' , [Pincode]= '" + pincode.Text + "' , [City] = '" + city.Text + "' , [State] ='" + txtState.Text + "' , " + "[Country]='" + country.Text + "' ,[Phone_No]='" + phoneno.Text + "' , [FaxNo]='" + faxno.Text + "' ,[E_MailID]='" + email.Text + "' , [DateOfIncorp]='" + datofincorp.Text + "' , " + "[OwnerName1]='" + ownname1.Text + "' , [OwnerName2]='" + ownname2.Text + "' , [MobileNo1]='" + ownmob1.Text + "' , [MobileNo2]='" + ownmob2.Text + "' , [PANo]='" + panno.Text + "' , " + "[Jurisdication]='" + juris.Text + "' , [Company_sht_code]='" + txtShortCode.Text + "' , [CINno]='" + cin_no.Text + "' ,[LogoImage] = null,[Assese_type]='No' " + ",[Modify_by] = '" + username + "',[Modify_Date] = '" + System.DateTime.Now.ToString("MM/dd/yyyy") + "' where [Company_Name] = '" + compname.Text + "'"; affect = objCon.affect(save); } dr.Close(); string str = "select [Company_ID] from [Company_Master] where [Company_Name] = '" + compname.Text + "'"; dr = objCon.getData(str); if (dr.HasRows) { while (dr.Read()) { compid = dr[0].ToString(); } } dr.Close(); string save2 = "update [Bank_details] set [bank_name]='" + txt_bankname.Text + "' , [bank_branch]='" + txtbranch.Text + "',[account_name]='" + txt_ac_name.Text + "' , [account_no]='" + txt_ac_no.Text + "' , " + "[IFSC_code]='" + txtifsc_code.Text + "' , [MICR_code]='" + txtMicr_code.Text + "',[Modify_by] = '" + username + "',[Modify_Date] ='" + System.DateTime.Now.ToString("MM/dd/yyyy") + "' where [comp_id] = '" + compid + "'"; affect = objCon.affect(save2); } MessageBox.Show("Saved Successfully...", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information); compname.Text = ""; add1.Text = ""; add2.Text = ""; add3.Text = ""; datofincorp.Text = System.DateTime.Now.ToString("dd/MM/yyyy"); busline.Text = ""; ownname1.Text = ""; ownname2.Text = ""; ownmob1.Text = ""; ownmob2.Text = ""; pincode.Text = ""; city.Text = ""; //comboBox1.SelectedIndex = -1; txtState.Text = ""; country.Text = ""; phoneno.Text = ""; faxno.Text = ""; email.Text = ""; panno.Text = ""; txt_bankname.Text = ""; txt_ac_no.Text = ""; txt_ac_name.Text = ""; txtbranch.Text = ""; cin_no.Text = ""; txtgst_no.Text = ""; juris.Text = ""; pictureBox1.Image = null; txtShortCode.Text = ""; txtifsc_code.Text = ""; txtMicr_code.Text = ""; textBox1.Text = ""; } catch { } } }
private void button4_Click(object sender, EventArgs e) { if (Validation() == true) { string ans = (MessageBox.Show("Do you want to Continue Save", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Information)).ToString(); if (ans == "Yes") { try { string str5 = "select [dbo].[GenPurchaseOrderNo] ('" + dtpPO_Date.Value.ToString("MM/dd/yyyy") + "','" + company + "')"; dr = ObjCon.getData(str5); if (dr.HasRows) { while (dr.Read()) { txtPONo.Text = dr[0].ToString(); } } dr.Close(); } catch { } try { dr.Close(); string conString = "Data Source=SERVER;Initial Catalog=BMSLifestyle;User ID=sa;Password=preet@1234"; con = new SqlConnection(conString); con.Open(); cmd = new SqlCommand("PurchaseOrderSave", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@PONo", txtPONo.Text)); cmd.Parameters.Add(new SqlParameter("@SupName", cmbSupName.Text)); cmd.Parameters.Add(new SqlParameter("@Mobile", txtMob.Text)); cmd.Parameters.Add(new SqlParameter("@sup_state", cmbState.Text.ToUpper())); cmd.Parameters.Add(new SqlParameter("@sup_gst_no", txtgstno.Text)); cmd.Parameters.Add(new SqlParameter("@sup_email", txtemail.Text)); cmd.Parameters.Add(new SqlParameter("@PODate", dtpPO_Date.Value.ToString("MM/dd/yyyy"))); cmd.Parameters.Add(new SqlParameter("@PaymentMode", "")); cmd.Parameters.Add(new SqlParameter("@TotalAmt", lblTot_Amt.Text)); cmd.Parameters.Add(new SqlParameter("@TotalGST", lblTotalgst.Text)); cmd.Parameters.Add(new SqlParameter("@CGSTAmt", lblcgstamt.Text)); cmd.Parameters.Add(new SqlParameter("@SGSTAmt", lblsgstamt.Text)); cmd.Parameters.Add(new SqlParameter("@IGSTAmt", lbligstamt.Text)); cmd.Parameters.Add(new SqlParameter("@NetAmt", lblNet_Amt.Text)); cmd.Parameters.Add(new SqlParameter("@Balance", lblNet_Amt.Text)); cmd.Parameters.Add(new SqlParameter("@Advance", "0")); cmd.Parameters.Add(new SqlParameter("@RecAmt", "0.00")); //cmd.Parameters.Add(new SqlParameter("@TWt_ingm", txtweightGm.Text)); //cmd.Parameters.Add(new SqlParameter("@TWt_inKg", txtweightKG.Text)); cmd.Parameters.Add(new SqlParameter("@EnterBy", username)); cmd.Parameters.Add(new SqlParameter("@Company", company)); cmd.Parameters.Add(new SqlParameter("@deleteflag", "No")); cmd.Parameters.Add(new SqlParameter("@narration", txtNarration.Text)); cmd.ExecuteNonQuery(); try { string strfk = "select ISNULL(MAX([PO_Pk]),0) FROM [Purchase_Order]"; dr = ObjCon.getData(strfk); if (dr.HasRows) { while (dr.Read()) { purchaseOrderPK = dr[0].ToString(); } } dr.Close(); } catch { } int row = Convert.ToInt32(dataGridView1.RowCount.ToString()) - 2; for (int i = 0; i <= row; i++) { cmd = new SqlCommand("SubPurchaseOrderSave", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@PO_Fk ", purchaseOrderPK)); cmd.Parameters.Add(new SqlParameter("@SubPONo ", txtPONo.Text)); cmd.Parameters.Add(new SqlParameter("@ItemName", dataGridView1.Rows[i].Cells["Column1"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@EACCode", dataGridView1.Rows[i].Cells["barcode1"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@SKU_code", dataGridView1.Rows[i].Cells["skucode"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@Ship_weight", dataGridView1.Rows[i].Cells["shipping_wt1"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@Groups", dataGridView1.Rows[i].Cells["group"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@size", dataGridView1.Rows[i].Cells["size"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@unit1", dataGridView1.Rows[i].Cells["unit"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@P_QTY", dataGridView1.Rows[i].Cells["qty1"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@Qty", dataGridView1.Rows[i].Cells["qty1"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@Rate", dataGridView1.Rows[i].Cells["rate1"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@Disc_per", dataGridView1.Rows[i].Cells["disc"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@new_rate", dataGridView1.Rows[i].Cells["newrate1"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@Amt", dataGridView1.Rows[i].Cells["amount1"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@cgsttax", dataGridView1.Rows[i].Cells["cgst_per"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@cgstamt", dataGridView1.Rows[i].Cells["cgst_amt"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@sgsttax", dataGridView1.Rows[i].Cells["sgst_per"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@sgstamt", dataGridView1.Rows[i].Cells["sgst_amt"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@igsttax", dataGridView1.Rows[i].Cells["igst_per"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@igstamt", dataGridView1.Rows[i].Cells["igst_amt"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@gst_amt", dataGridView1.Rows[i].Cells["gst_amt"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@GST_per", dataGridView1.Rows[i].Cells["GST_per"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@total_amount", dataGridView1.Rows[i].Cells["Tamt"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@MRP_Sale", dataGridView1.Rows[i].Cells["MRP"].Value.ToString())); cmd.Parameters.Add(new SqlParameter("@Returned", "No")); cmd.Parameters.Add(new SqlParameter("@Company", company)); cmd.Parameters.Add(new SqlParameter("@EnterBy", username)); cmd.Parameters.Add(new SqlParameter("@DeleteFlag", "No")); cmd.ExecuteNonQuery(); } if (cmbSupName.Text != "") { try { if (flag1 == 0) { dr.Close(); string save3 = "INSERT INTO [Supplier]([SupName],[Mobile],[EmailId],[GST_No],[state],[Enter_by],[Enter_date],[Company])VALUES" + "('" + cmbSupName.Text + "','" + txtMob.Text + "','" + txtemail.Text + "','" + txtgstno.Text + "','" + cmbState.Text + "','" + username + "',getDate(),'" + company + "')"; affect = ObjCon.affect(save3); } } catch { } } MessageBox.Show("Saved Successfully...", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information); clear(); } catch { } } } }