Exemple #1
0
        public void MakePayment()
        {
            decimal totalamt    = 0;
            int     UserId      = int.Parse(ddlUser.SelectedValue);
            var     products    = ProductAddtoCartMasterCollection.GetAll().FindAll(x => x.User_id == UserId);
            var     paymentBill = new ProductBill_Master();

            paymentBill.BILL_ID = ProductBill_Master.MaxId() + 1;
            paymentBill.BILLNO  = DateTime.Now.ToString("yyyyMMddHHmmssffff");
            foreach (GridViewRow gv in gdvNotice.Rows)
            {
                totalamt += decimal.Parse(gv.Cells[4].Text.ToString());
            }
            paymentBill.TOTAL         = totalamt;
            paymentBill.STATUS        = "Wallet";
            paymentBill.BILLDATE      = DateTime.Today.Date;
            paymentBill.RECEIVER_ID   = UserId;
            paymentBill.REMARKS       = null;
            paymentBill.LOGIN_ID      = int.Parse(Session["PickupID"].ToString());
            paymentBill.Bil_Stutas    = "Paid";
            paymentBill.Extra_Payment = 0;
            paymentBill.NO_OF_BOXES   = "";
            paymentBill.Save();
            #region
            foreach (var x in products)
            {
                ProductInvoice_Master invoiceItem = new ProductInvoice_Master();
                {
                    invoiceItem.INVOICE_ID = ProductInvoice_Master.MaxId() + 1;
                    invoiceItem.ITEM_ID    = x.Product_id;
                    invoiceItem.ITEMNAME   = PickUpItemMaster.GetByOrderId(x.Product_id).ITEMNAME;
                    invoiceItem.HSNCODE    = PickUpItemMaster.GetByOrderId(x.Product_id).HSNCODE;
                    invoiceItem.QUANTITY   = x.Quantity;
                    invoiceItem.RATE_PER   = PickUpItemMaster.GetByOrderId(x.Product_id).RATE_PER;
                    invoiceItem.TOTAL      = x.Total;
                    if (paymentBill.RECEIVER_ID == paymentBill.LOGIN_ID)
                    {
                        invoiceItem.CGST_RATE = decimal.Parse(PickUpItemMaster.GetByOrderId(x.Product_id).CGST.ToString());
                        invoiceItem.SGST_RATE = decimal.Parse(PickUpItemMaster.GetByOrderId(x.Product_id).SGST.ToString());
                        invoiceItem.IGST_RATE = 0;
                        invoiceItem.CGST_AMT  = (invoiceItem.TOTAL * invoiceItem.CGST_RATE) / 100;
                        invoiceItem.SGST_AMT  = (invoiceItem.TOTAL * invoiceItem.SGST_RATE) / 100;
                        invoiceItem.IGST_AMT  = (invoiceItem.TOTAL * invoiceItem.IGST_RATE) / 100;
                    }
                    else
                    {
                        invoiceItem.CGST_RATE = 0;
                        invoiceItem.SGST_RATE = 0;
                        invoiceItem.IGST_RATE = decimal.Parse(PickUpItemMaster.GetByOrderId(x.Product_id).IGST.ToString());
                        invoiceItem.CGST_AMT  = (invoiceItem.TOTAL * invoiceItem.CGST_RATE) / 100;
                        invoiceItem.SGST_AMT  = (invoiceItem.TOTAL * invoiceItem.SGST_RATE) / 100;
                        invoiceItem.IGST_AMT  = (invoiceItem.TOTAL * invoiceItem.IGST_RATE) / 100;
                    }
                    invoiceItem.BILL_ID      = paymentBill.BILL_ID;
                    invoiceItem.REMARKS      = "";
                    invoiceItem.INVOICE_DATE = System.DateTime.Today;
                    invoiceItem.Bil_Stutas   = "Waiting";
                    invoiceItem.RECEIVER_ID  = paymentBill.RECEIVER_ID;
                    invoiceItem.UnitCode     = x.UnitCode;
                    invoiceItem.Color_Code   = x.Color_Code;
                }
                invoiceItem.Save();
                #endregion
                ProductAddtoCartMaster dm = new ProductAddtoCartMaster();
                dm.UserDelete(UserId);
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Save Successfully...');</Script>", false);
                PrintBill();
            }
        }
Exemple #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);
     }
 }