private void btndelete_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Do you want to Delete Bill?", "Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { getcon(); if (con.State == ConnectionState.Open) { con.Close(); } con.Open(); //SqlCommand cmd = new SqlCommand("update PurchaseOrderMaster set isactive=0 where VchNo='" + txtVchNo.Text + "' and CompanyId=" + compid + "", con); //cmd.ExecuteNonQuery(); string qry = "update PurchaseOrderMaster set isactive=0 where VchNo='" + txtVchNo.Text + "' and CompanyId=" + compid + ""; SqlCommand cmd = new SqlCommand(qry, con); LogGenerator.Info(qry); cmd.ExecuteNonQuery(); lcon.execute("Insert into sync values('" + qry.Replace("'", "\"") + "')"); SqlCommand cmd2 = new SqlCommand("update PurchaseOrderProductMaster set isactive=0 where VchNo='" + txtVchNo.Text + "'and CompanyId=" + compid, con); cmd2.ExecuteNonQuery(); string qry1 = "update PurchaseOrderProductMaster set isactive=0 where VchNo='" + txtVchNo.Text + "' and CompanyId=" + compid + ""; lcon.execute("Insert into sync values('" + qry1.Replace("'", "\"") + "')"); LogGenerator.Info(qry1); clearall(); clearitem(); LVFO.Clear(); this.Close(); DateWisePurchaseReport frm = new DateWisePurchaseReport(); frm.MdiParent = this.MdiParent; frm.StartPosition = FormStartPosition.CenterScreen; frm.Show(); } else { if (cmbPurchaseType.Text == "" || cmbCustName.Text == "" || cmbTerms.Text == "") { MessageBox.Show("Please fill all the information."); if (cmbPurchaseType.Text == "") { cmbPurchaseType.Focus(); } else if (cmbCustName.Text == "") { cmbCustName.Focus(); } else if (cmbTerms.Text == "") { cmbTerms.Focus(); } } } }
private void btndelete_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Do you want to Delete Purchase Return?", "Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { getcon(); if (con.State == ConnectionState.Open) { con.Close(); } con.Open(); SqlCommand cmd = new SqlCommand("update billmaster set isactive=0 where Bill_No='" + txtVchNo.Text + "' and billtype='PR' and CompanyId=" + Master.companyId + "", con); cmd.ExecuteNonQuery(); SqlCommand cmd2 = new SqlCommand("update billproductmaster set isactive=0 where Bill_No='" + txtVchNo.Text + "' and BillType='PR'", con); cmd2.ExecuteNonQuery(); SqlCommand cmd1 = new SqlCommand("update Ledger set isactive=0 where VoucherId='" + txtVchNo.Text + "' and TranType='PurchaseReturn' and CompanyId=" + Master.companyId + "", con); cmd2.ExecuteNonQuery(); clearall(); clearitem(); LVFO.Clear(); this.Close(); PurchaseReturnList frm = new PurchaseReturnList(); frm.MdiParent = this.MdiParent; frm.StartPosition = FormStartPosition.CenterScreen; frm.Show(); } else { if (cmbPurchaseType.Text == "" || cmbCustName.Text == "" || cmbTerms.Text == "") { MessageBox.Show("Please fill all the information."); if (cmbPurchaseType.Text == "") { cmbPurchaseType.Focus(); } else if (cmbCustName.Text == "") { cmbCustName.Focus(); } else if (cmbTerms.Text == "") { cmbTerms.Focus(); } } } }