Example #1
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        bool    result           = true;
        int     BranchOrderID    = 0;
        int     productID        = 0;
        decimal TotalNetQuantity = 0;
        decimal NetQuantity      = 0;
        string  OrderID          = Encrypt_Decrypt.Decrypt(Session["sOrderID"].ToString().Trim(), true);
        string  comment          = string.Empty;
        string  OrderToID        = string.Empty;
        int     OrderTo          = 1;

        if (ddlSelectBranch.SelectedIndex > 0)
        {
            if (rblBranchSupplier.SelectedValue == "1")
            {
                OrderTo = 1;
            }
            else if (rblBranchSupplier.SelectedValue == "2")
            {
                OrderTo = 2;
            }
            OrderToID = ddlSelectBranch.SelectedValue;
            comment   = "<br/>" + string.Format("{0:dd MMM yyyy}", DateTime.Now) + ' ' + "INPROCESS";
            result    = orderobj.BranchOrderInsert(Convert.ToInt32(OrderID), Convert.ToDecimal(lblTotalprice.Text), BranchOrderStatus.New, lblBPO.Text, Convert.ToDateTime(lblDate.Text), "Bhanu", string.Empty, comment, MudarApp.Insert, ref BranchOrderID, OrderTo, OrderToID);
            if (result)
            {
                decimal TotalPriceAmt = 0;
                foreach (GridViewRow gvr in gvPurchaseOrder.Rows)
                {
                    var lblQuantity         = gvr.FindControl("lblQuantity") as Label;
                    var lblPacking25        = gvr.FindControl("lblPacking25") as Label;
                    var lblPacking180       = gvr.FindControl("lblPacking180") as Label;
                    var lblPOUPPrice        = gvr.FindControl("lblPOUPPrice") as Label;
                    var lblTotalPriceAmount = gvr.FindControl("lblTotalPriceAmount") as Label;
                    var lblProductID        = gvr.FindControl("lblProductID") as Label;
                    (gvr.Cells[7].FindControl("lblTotalPriceAmount") as Label).Text = string.Format("{0:0.00}", (Convert.ToDecimal(lblQuantity.Text) * Convert.ToDecimal(lblPOUPPrice.Text)));
                    productID        = Convert.ToInt32(lblProductID.Text);
                    NetQuantity      = Convert.ToDecimal(lblQuantity.Text);
                    TotalNetQuantity = TotalNetQuantity + NetQuantity;
                    result           = orderobj.BranchOrderProduct_INSandUPDandDEL(BranchOrderID, productID, NetQuantity, 0, Convert.ToDecimal(lblTotalPriceAmount.Text), Convert.ToDecimal(lblPOUPPrice.Text), "Bhanu", string.Empty, MudarApp.Insert);
                    TotalPriceAmt   += Convert.ToDecimal(lblTotalPriceAmount.Text);
                }
                result = orderobj.OrderDetails_UPD(Convert.ToInt32(OrderID), OrderStatus.Inprocess, "Bhanu", string.Empty);
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>alert('Please select Branch/Supplier to place Order THanks...!');</script>");
            return;
        }
        if (result)
        {
            dtOrder = orderobj.OrderList(Convert.ToInt32(OrderID));
            if (dtOrder.Rows.Count > 0)
            {
                DataRow dr = dtOrder.Rows[0];
                if (dr["OrderType"].ToString() != "order")
                {
                    generatePDFforLotsample(BranchOrderID, OrderID);
                    SendmailforOrderDetails(dr["OrderType"].ToString(), OrderID.ToString());
                }
                else
                {
                    generatePDFforPO(BranchOrderID, lblBPO.Text);
                    SendmailforOrderDetails(dr["OrderType"].ToString(), OrderID.ToString());
                }
            }
            Response.Redirect("../mudar/UpdateAdminOrder.aspx");
        }
    }