Пример #1
0
        protected void linkbtnEdit_Click(object sender, EventArgs e)
        {
            LinkButton  lb = (LinkButton)sender;
            GridViewRow gr = (GridViewRow)lb.NamingContainer;

            ViewState["id"] = ((Label)gr.FindControl("labelNOTICE_ID")).Text;
            string nid = ViewState["id"].ToString();
            ProductInvoice_Master dm = ProductInvoice_Master.GetByINVOICE_ID(int.Parse(nid));

            ddlItem.SelectedValue = dm.ITEM_ID.ToString();
            txtItemCode.Text      = ITEM_MASTER.GetByITEM_ID(ddlItem.SelectedIndex).CODE;
            txtcgst.Text          = dm.CGST_RATE.ToString();
            txtsgst.Text          = dm.SGST_RATE.ToString();
            txtigst.Text          = dm.IGST_RATE.ToString();
            numqty.Text           = dm.QUANTITY.ToString();
            txtrate.Text          = dm.RATE_PER.ToString();
            btnsave.Text          = "Update";
        }
Пример #2
0
 protected void btnsave_Click(object sender, EventArgs e)
 {
     try
     {
         decimal maxrateigst      = 0;
         decimal total            = 0;
         ProductInvoice_Master ln = new ProductInvoice_Master();
         total = decimal.Parse(numqty.Text) * decimal.Parse(txtrate.Text.Trim());
         if (btnsave.Text == "Submit")
         {
             if (string.IsNullOrEmpty(numqty.Text))
             {
                 ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Plz Enter Quantity..');</Script>", false);
                 numqty.Focus();
                 return;
             }
             else
             {
                 decimal qt = decimal.Parse(numqty.Text.Trim());
                 if (qt <= 0)
                 {
                     ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Quantity must be greater than zero..');</Script>", false);
                     numqty.Focus();
                     return;
                 }
             }
             ln.INVOICE_ID = ProductInvoice_Master.MaxId() + 1;
             ln.ITEM_ID    = int.Parse(ddlItem.SelectedValue);
             ln.ITEMNAME   = ITEM_MASTER.GetByITEM_ID(ln.ITEM_ID).ITEMNAME;
             ln.HSNCODE    = ITEM_MASTER.GetByITEM_ID(ln.ITEM_ID).HSNCODE;
             ln.QUANTITY   = decimal.Parse(numqty.Text);
             ln.RATE_PER   = decimal.Parse(txtrate.Text.Trim());
             ln.TOTAL      = total;
             decimal cgst = decimal.Parse(txtcgst.Text.Trim());
             decimal sgst = decimal.Parse(txtsgst.Text.Trim());
             decimal igst = decimal.Parse(txtigst.Text.Trim());
             if (cgst > maxrate)
             {
                 maxrate = cgst;
             }
             if (sgst > maxrate)
             {
                 maxrate = sgst;
             }
             if (igst > maxrate)
             {
                 maxrate = igst;
             }
             maxrateigst     = maxrate;
             ln.CGST_AMT     = (total * cgst) / 100;
             ln.SGST_AMT     = (total * sgst) / 100;
             ln.IGST_AMT     = (total * igst) / 100;
             ln.CGST_RATE    = cgst;
             ln.SGST_RATE    = sgst;
             ln.IGST_RATE    = igst;
             ln.BILL_ID      = billid;
             ln.REMARKS      = "";
             ln.INVOICE_DATE = System.DateTime.Today;
             ln.Bil_Stutas   = "Waiting";
             ln.Save();
         }
         else if (btnsave.Text == "Update")
         {
             ln            = ProductInvoice_Master.GetByINVOICE_ID(int.Parse(ViewState["id"].ToString()));
             ln.INVOICE_ID = int.Parse(ViewState["id"].ToString());
             ln.ITEM_ID    = int.Parse(ddlItem.SelectedValue);
             ln.ITEMNAME   = ITEM_MASTER.GetByITEM_ID(ln.ITEM_ID).ITEMNAME;
             ln.HSNCODE    = ITEM_MASTER.GetByITEM_ID(ln.ITEM_ID).HSNCODE;
             ln.QUANTITY   = decimal.Parse(numqty.Text);
             ln.RATE_PER   = decimal.Parse(txtrate.Text.Trim());
             ln.TOTAL      = total;
             decimal cgst = decimal.Parse(txtcgst.Text.Trim());
             decimal sgst = decimal.Parse(txtsgst.Text.Trim());
             decimal igst = decimal.Parse(txtigst.Text.Trim());
             if (cgst > maxrate)
             {
                 maxrate = cgst;
             }
             if (sgst > maxrate)
             {
                 maxrate = sgst;
             }
             if (igst > maxrate)
             {
                 maxrate = igst;
             }
             maxrateigst     = maxrate;
             ln.CGST_AMT     = (total * cgst) / 100;
             ln.SGST_AMT     = (total * sgst) / 100;
             ln.IGST_AMT     = (total * igst) / 100;
             ln.CGST_RATE    = cgst;
             ln.SGST_RATE    = sgst;
             ln.IGST_RATE    = igst;
             ln.BILL_ID      = billid;
             ln.REMARKS      = "";
             ln.INVOICE_DATE = System.DateTime.Today;
             ln.Bil_Stutas   = "Waiting";
             ln.Save();
             ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Update Successfully...');</Script>", false);
         }
         grid();
         ddlItem.SelectedIndex = 0;
         ClearControls(this);
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert(error);</script>", false);
     }
 }