Esempio n. 1
0
        public void submit()
        {
            {
                try
                {
                    if (txtprintname.Text == "")
                    {
                        MessageBox.Show("Enter Sale Type");
                        txtprintname.Focus();
                        return;
                    }
                    else
                    {
                        if (btnsave.Text == "Update")
                        {
                            string chkecom1;
                            if (chkecom.Checked == true)
                            {
                                chkecom1 = "1";
                            }
                            else
                            {
                                chkecom1 = "0";
                            }
                            cn.execute("UPDATE [dbo].[PurchasetypeMaster]SET [Purchasetypename] = '" + txtprintname.Text + "',[Groupid] = '" + txtgrop.SelectedValue + "',[taxtypeid] = '" + cmbxttype.SelectedValue + "',[TaxTypename] = '" + cmbxttype.Text + "',[Region] = '" + cmbregion.Text + "',[type]='S',[Prefix]='" + txtinvoiceprefix.Text + "',[startingno]='" + txtstartfrom.Text + "',TaxCalculation='" + cmbtaxcal.Text + "',PickupPrice='" + cmbbtdefault.Text + "',InvoiceHeading='" + txtinvoiceheading.Text + "',FormType='" + cmbformtype.Text + "',chkecom='" + chkecom1 + "',txtecom='" + txtecom.Text + "',[isactive] = 1 WHERE purchasetypename='" + id + "'");
                            MessageBox.Show("Update Successfully");
                            DialogResult dr = MessageBox.Show("Do you want to Include This Sale Type/Purchase Type To All Tax Slab?", "Tax Slab", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (dr == DialogResult.Yes)
                            {
                                inserttaxslab();
                            }

                            try
                            {
                                defaultSale.bindsaletype();
                            }
                            catch
                            {
                            }
                            try
                            {
                                defaultSaleOrder.bindsaletype();
                            }
                            catch
                            {
                            }
                            try
                            {
                                stockinout.bindsaletype();
                            }
                            catch
                            {
                            }
                            try
                            {
                                salePurchaseOrderSimpleformate.bindsaletype();
                            }
                            catch
                            {
                            }
                            if (string.IsNullOrEmpty(pvc) == true)
                            {
                                master.RemoveCurrentTab();
                            }
                            else
                            {
                                master.RemoveCurrentTab1(pvc, txtprintname.Text);
                            }
                            clear();
                        }
                        else
                        {
                            string chkecom1;
                            if (chkecom.Checked == true)
                            {
                                chkecom1 = "1";
                            }
                            else
                            {
                                chkecom1 = "0";
                            }

                            SqlCommand     cmdRecordExist = new SqlCommand("SELECT * FROM PurchasetypeMaster WHERE isactive=1 AND Purchasetypename='" + txtprintname.Text + "' AND FormType='" + cmbformtype.Text + "'", con);
                            SqlDataAdapter sdaRecordExist = new SqlDataAdapter(cmdRecordExist);
                            DataTable      recordExistDt  = new DataTable();
                            sdaRecordExist.Fill(recordExistDt);

                            if (recordExistDt.Rows.Count > 0)
                            {
                                MessageBox.Show("Sale Type " + txtprintname.Text + " is already exist");
                                clear();
                                return;
                            }
                            else
                            {
                                cn.execute("INSERT INTO [dbo].[PurchasetypeMaster]([Purchasetypename],[Groupid],[taxtypeid],[TaxTypename],[Region],[isactive],[Prefix],[startingno],[TaxCalculation],[PickupPrice],[InvoiceHeading],[FormType],[chkecom],[txtecom],[type])VALUES('" + txtprintname.Text + "','" + txtgrop.SelectedValue + "','" + cmbxttype.SelectedValue + "','" + cmbxttype.Text + "','" + cmbregion.Text + "','" + 1 + "','" + txtinvoiceprefix.Text + "','" + txtstartfrom.Text + "','" + cmbtaxcal.Text + "','" + cmbbtdefault.Text + "','" + txtinvoiceheading.Text + "','" + cmbformtype.Text + "','" + chkecom1 + "','" + txtecom.Text + "','S')");

                                MessageBox.Show("Insert Successfully");
                                DialogResult dr = MessageBox.Show("Do you want to Include This Sale Type To All Tax Slab?", "Tax Slab", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                                if (dr == DialogResult.Yes)
                                {
                                    inserttaxslab();
                                }

                                try
                                {
                                    defaultSale.bindsaletype();
                                }
                                catch
                                {
                                }
                                try
                                {
                                    defaultSaleOrder.bindsaletype();
                                }
                                catch
                                {
                                }
                                try
                                {
                                    stockinout.bindsaletype();
                                }
                                catch
                                {
                                }
                                try
                                {
                                    salePurchaseOrderSimpleformate.bindsaletype();
                                }
                                catch
                                {
                                }
                                if (string.IsNullOrEmpty(pvc) == true)
                                {
                                    master.RemoveCurrentTab();
                                }
                                else
                                {
                                    master.RemoveCurrentTab1(pvc, txtprintname.Text);
                                }
                                clear();
                            }
                        }
                    }
                }
                catch
                {
                }
            }
        }