예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtTaxName.Text.Length == 0)
            {
                MessageBox.Show("Kindly enter tax name.");
                txtTaxName.Focus();
                return;
            }

            if (mPkValue == 0)
            {
                TaxMst objtxm = new TaxMst();

                objtxm.TaxName = txtTaxName.Text;
                //objtxm.IGST = Convert.ToDecimal(Convert.ToDouble(txtIGST.Text));
                //objtxm.CGST = Convert.ToDecimal(Convert.ToDouble(txtCGST.Text));
                //objtxm.SGST = Convert.ToDecimal(Convert.ToDouble(txtSGST.Text));
                objtxm.IGST = AppFun.ToDecimal(txtIGST.Text);
                objtxm.CGST = AppFun.ToDecimal(txtCGST.Text);
                objtxm.SGST = AppFun.ToDecimal(txtSGST.Text);

                dbx.TaxMsts.Add(objtxm);
                dbx.SaveChanges();

                MessageBox.Show("Tax detail saved..");
            }
            else
            {
                var objtxm = dbx.TaxMsts.Where(u => u.TaxId == mPkValue).First();
                if (objtxm != null)
                {
                    objtxm.TaxName = txtTaxName.Text;
                    objtxm.IGST    = AppFun.ToDecimal(txtIGST.Text);
                    objtxm.CGST    = AppFun.ToDecimal(txtCGST.Text);
                    objtxm.SGST    = AppFun.ToDecimal(txtSGST.Text);

                    dbx.SaveChanges();
                    MessageBox.Show("Item detail updated..");
                }
            }
            ClearControls();
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtItemName.Text.Length == 0)
            {
                MessageBox.Show("Kindly enter item name.");
                txtItemName.Focus();
                return;
            }
            if (cmbTax.Text.Length == 0)
            {
                MessageBox.Show("Kindly select tax.");
                cmbTax.Focus();
                return;
            }

            cmbTax.Tag = dbx.TaxMsts.Where(u => u.TaxName == cmbTax.Text.Trim()).Select(s => s.TaxId).FirstOrDefault();

            if (mPkValue == 0)
            {
                ItemMst objitm = new ItemMst();

                objitm.ItemName      = txtItemName.Text;
                objitm.ItemCode      = txtItemCode.Text;
                objitm.Unit          = cmbUnit.Text;
                objitm.ItemDesc      = txtItemDesc.Text;
                objitm.TaxId         = Convert.ToInt32(cmbTax.Tag);
                objitm.IGSTPer       = AppFun.ToDecimal(txtIGST.Text);
                objitm.CGSTPer       = AppFun.ToDecimal(txtCGST.Text);
                objitm.SGSTPer       = AppFun.ToDecimal(txtSGST.Text);
                objitm.PurchasePrice = AppFun.ToDecimal(txtPurchasePrice.Text);
                objitm.SalePrice     = AppFun.ToDecimal(txtSalePrice.Text);
                objitm.HSNCode       = txtHSNCode.Text;

                dbx.ItemMsts.Add(objitm);
                dbx.SaveChanges();

                MessageBox.Show("Item detail saved..");
            }
            else
            {
                var objitm = dbx.ItemMsts.Where(u => u.ItemId == mPkValue).First();
                if (objitm != null)
                {
                    objitm.ItemName      = txtItemName.Text;
                    objitm.ItemCode      = txtItemCode.Text;
                    objitm.Unit          = cmbUnit.Text;
                    objitm.ItemDesc      = txtItemDesc.Text;
                    objitm.TaxId         = Convert.ToInt32(cmbTax.Tag);
                    objitm.IGSTPer       = Convert.ToDecimal(txtIGST.Text);
                    objitm.CGSTPer       = Convert.ToDecimal(txtCGST.Text);
                    objitm.SGSTPer       = Convert.ToDecimal(txtSGST.Text);
                    objitm.PurchasePrice = Convert.ToDecimal(txtPurchasePrice.Text);
                    objitm.SalePrice     = Convert.ToDecimal(txtSalePrice.Text);
                    objitm.HSNCode       = txtHSNCode.Text;

                    dbx.SaveChanges();
                    MessageBox.Show("Item detail updated..");
                }
            }

            var lqryu = dbx.UnitMsts.Where(u => u.UnitName == cmbUnit.Text.Trim());

            if (lqryu.Count() == 0)
            {
                UnitMst objumt = new UnitMst();
                objumt.UnitName = cmbUnit.Text;
                dbx.UnitMsts.Add(objumt);
                dbx.SaveChanges();
                HelperClass.bCombBox_Unit(cmbUnit);
            }
            ClearControls();
        }