コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["user"] == null)
            {
                Response.Redirect("~/Default.aspx");
            }
            DataTable table = GetTable();

            if (!IsPostBack)
            {
                if (Request.QueryString["alert"] == "notpass")
                {
                    Response.Write("<script>alert('لم يتم الحفظ');</script>");
                }

                if (Request.QueryString["id"].ToString() != null)
                {
                    if (Convert.ToInt32(Request.QueryString["id"].ToString()) > 0)
                    {
                        SalesOrder salesOrder = new ClsSalesOrder().get(Convert.ToInt32(Request.QueryString["id"].ToString()));
                        ddlCustomer.SelectedValue = salesOrder.CustomerID.ToString();
                        txtDeliveryDate.Text      = salesOrder.DeliveryDate.ToString();
                        txtRemarks.Text           = salesOrder.Remarks.ToString();
                        for (int i = 0; i < salesOrder.SalesOrderItems.Count; i++)
                        {
                            DataRow dr = table.NewRow();
                            dr["ProductID"] = salesOrder.SalesOrderItems[i].ProductWarehouseID;
                            dr["Price"]     = salesOrder.SalesOrderItems[i].Price;
                            dr["Quantity"]  = salesOrder.SalesOrderItems[i].Quantity;
                            dr["Discount"]  = salesOrder.SalesOrderItems[i].Discount;
                            dr["Total"]     = (salesOrder.SalesOrderItems[i].Price * salesOrder.SalesOrderItems[i].Quantity) - salesOrder.SalesOrderItems[i].Discount;
                            table.Rows.Add(dr);
                        }
                        Session["SalesOrderItems"] = table;
                        //       Gbind();
                        btnSave.Visible = false;
                        btnEdit.Visible = false;
                    }
                    else
                    {
                        //  table = GetTable();
                        btnSave.Visible = true;
                        btnEdit.Visible = false;
                    }
                }
            }
        }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string     sql        = "select max(id)as lastID from Inv_SalesOrder";
            DataTable  dt         = DataAccess.ExecuteSQLQuery(sql);
            int        id         = int.Parse(dt.Rows[0]["lastID"].ToString()) + 1;
            SalesOrder salesOrder = new SalesOrder();

            salesOrder.OrderCode    = "OP" + id;
            salesOrder.CustomerID   = Convert.ToInt32(ddlCustomer.SelectedValue.ToString());
            salesOrder.DeliveryDate = Convert.ToDateTime(txtDeliveryDate.Text);
            salesOrder.Remarks      = txtRemarks.Text;
            salesOrder.Active       = 1;
            DataTable             dt2             = Session["SalesOrderItems"] as DataTable;
            List <SalesOrderItem> salesOrderItems = new List <SalesOrderItem>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                SalesOrderItem salesOrderItem = new SalesOrderItem();
                salesOrderItem.ProductWarehouseID = Convert.ToInt32(dt.Rows[i]["ProductID"].ToString());
                salesOrderItem.Quantity           = Convert.ToInt32(dt.Rows[i]["Quantity"].ToString());
                salesOrderItem.Price    = Convert.ToDouble(dt.Rows[i]["Cost"].ToString());
                salesOrderItem.Discount = Convert.ToDouble(dt.Rows[i]["Discount"].ToString());
                salesOrderItem.Active   = 1;
                salesOrderItems.Add(salesOrderItem);
            }
            salesOrder.SalesOrderItems = salesOrderItems;
            HttpCookie myCookie = Request.Cookies["user"];

            salesOrder.OperatorID = Convert.ToInt32(myCookie.Values["userid"].ToString());
            int res = new ClsSalesOrder().insert(salesOrder);

            if (res > 0)
            {
                Response.Redirect("~/Inventory/SalesOrders.aspx?alert=success");
            }
            else
            {
                Response.Redirect("~/Inventory/NewSalesOrder.aspx?id=0&&alret=notpass");
            }
        }
コード例 #3
0
    protected void BtnAppRejSave_Click(object sender, EventArgs e)
    {
        ClsSalesOrder clsSalses = new ClsSalesOrder();

        if (!string.IsNullOrEmpty(hidDetails_ID.Value))
        {
            //For Mails

            DataTable dtPODetMail = new DataTable();
            dtPODetMail.Columns.Add("CatagoryName", typeof(string));
            dtPODetMail.Columns.Add("ProductName", typeof(string));
            dtPODetMail.Columns.Add("Current_Stock", typeof(int));
            dtPODetMail.Columns.Add("Quantity", typeof(int));

            foreach (GridViewRow gvRow in GvwSaleseOrderDetails.Rows)
            {
                if (((Label)gvRow.FindControl("lblCatagory")).Text != "")
                {
                    int PendingQuantity = Convert.ToInt16(((Label)gvRow.FindControl("LblPendingQuantity")).Text);
                    int Current_Stock   = Convert.ToInt16(((Label)gvRow.FindControl("LblCurrentStock")).Text);
                    if (Current_Stock < PendingQuantity)
                    {
                        DataRow drDetMail = dtPODetMail.NewRow();
                        drDetMail["CatagoryName"]  = ((Label)gvRow.FindControl("lblCatagory")).Text;
                        drDetMail["ProductName"]   = ((Label)gvRow.FindControl("LblProduct")).Text;
                        drDetMail["Current_Stock"] = Convert.ToInt16(((Label)gvRow.FindControl("LblCurrentStock")).Text);
                        drDetMail["Quantity"]      = Convert.ToInt16(((Label)gvRow.FindControl("LblPendingQuantity")).Text);
                        dtPODetMail.Rows.Add(drDetMail);
                    }
                }
            }
            DataRow[] drModel = dtPODetMail.Select("Current_Stock=0");

            DataTable dtNew = new DataTable();
            dtNew = dtPODetMail.Clone();
            if (drModel.Length > 0)
            {
                foreach (DataRow dr in drModel)
                {
                    dtNew.ImportRow(dr);
                }
                dtNew.AcceptChanges();
            }

            if (dtNew.Rows.Count == GvwSaleseOrderDetails.Rows.Count)
            {
                if (txttype.Text != "Service" && txttype.Text != "Support" && txttype.Text != "Rental" && txttype.Text != "Any other services")
                {
                    int SentMailResult = clsSalses.Send_Mail_ZeroStock_So_ProductDetails(dtPODetMail, txtState.Text.Trim(), TxtLocation.Text.Trim());
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Stock is not available...');</script>", false);
                    Txt_AppRejReason.Text   = "";
                    DrpAppRej.SelectedIndex = 0;
                    GetSalesManager();

                    Panel2.Visible = true; Panel1.Visible = false;
                }
                else
                {
                    string asd    = hidDetails_ID.Value;
                    bool   result = ClsSalesManagerChecking.Update_SO_AppReject(Convert.ToInt32(asd), Convert.ToInt32(DrpAppRej.SelectedValue.Trim()), Txt_AppRejReason.Text.Trim(), Convert.ToInt32(Session["Id"]));

                    if (result)
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Saved Successfully...');</script>", false);
                        Txt_AppRejReason.Text   = "";
                        DrpAppRej.SelectedIndex = 0;
                        GetSalesManager();

                        Panel2.Visible = true; Panel1.Visible = false;
                    }

                    else
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Failed...');</script>", false);
                    }
                }
            }
            else
            {
                string asd    = hidDetails_ID.Value;
                bool   result = ClsSalesManagerChecking.Update_SO_AppReject(Convert.ToInt32(asd), Convert.ToInt32(DrpAppRej.SelectedValue.Trim()), Txt_AppRejReason.Text.Trim(), Convert.ToInt32(Session["Id"]));
                if (txttype.Text != "Service" && txttype.Text != "Support" && txttype.Text != "Rental" && txttype.Text != "Any other services")
                {
                    if (dtPODetMail.Rows.Count > 0)
                    {
                        int SentMailResult = clsSalses.Send_Mail_ZeroStock_So_ProductDetails(dtPODetMail, txtState.Text.Trim(), TxtLocation.Text.Trim());
                    }
                }
                if (result)
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Saved Successfully...');</script>", false);
                    Txt_AppRejReason.Text   = "";
                    DrpAppRej.SelectedIndex = 0;
                    GetSalesManager();

                    Panel2.Visible = true; Panel1.Visible = false;
                }

                else
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Failed...');</script>", false);
                }
            }
        }
    }
コード例 #4
0
    protected void BtnGRNSave_Click(object sender, EventArgs e)
    {
        try
        {
            ClsPurchaseInvoice objclsinvc = new ClsPurchaseInvoice();
            if (Txt_InvoiceDate.Text != string.Empty && TxtLorryRcptNum.Text != string.Empty)
            {
                foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                {
                    if (((TextBox)row.FindControl("TxtInQuantity")).Text == "")
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Enter GRN Quantity.');</script>", false);
                        return;
                    }
                    if (((TextBox)row.FindControl("TxtInQuantity")).Text != "0")
                    {
                        if (((TextBox)row.FindControl("txtSupRefNo")).Text == "")
                        {
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Enter Supplier Reference Number.');</script>", false);
                            return;
                        }
                        else if (((TextBox)row.FindControl("txtSupRefDate")).Text == "")
                        {
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select Supplier Reference Date.');</script>", false);
                            return;
                        }
                    }
                    //else if (Txt_InvoiceDate.Text != "")
                    // {
                    DateTime GRNDate = Convert.ToDateTime(Txt_InvoiceDate.Text);

                    string TxtSupRefDate = ((TextBox)row.FindControl("txtSupRefDate")).Text;
                    if (TxtSupRefDate.ToString() != string.Empty || TxtSupRefDate.ToString() != "")
                    {
                        DateTime SupRefDate = Convert.ToDateTime(TxtSupRefDate);

                        if (SupRefDate > GRNDate)
                        {
                            // lblshowmsg.Text = "Supper reference date can't be greater than GRN date.";
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Supper reference date can not be greater than GRN date.');</script>", false);
                            //ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Supper reference date can't be greater than GRN date.');</script>", false);
                            ((TextBox)row.FindControl("txtSupRefDate")).Focus();
                            return;
                        }
                    }

                    //}
                    double TxtInPriceUpdate      = Convert.ToDouble(((TextBox)row.FindControl("TxtInPrice")).Text);
                    double TxtInTotalPriceUpdate = Convert.ToDouble(((TextBox)row.FindControl("TxtInTotalPrice")).Text);
                    Int32  TxtInQuantityUpdate   = Convert.ToInt32(((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text);
                    double Sum    = Convert.ToDouble((TxtInPriceUpdate * TxtInQuantityUpdate).ToString("0.00"));
                    double prvSum = Convert.ToDouble(TxtInTotalPriceUpdate.ToString("0.00"));
                    if (Sum != prvSum)
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "<script type=text/javascript>alert('Please click on Update Button..')</script>");
                        Button BtnAdd = (Button)GvwPurchaseInvocie.FooterRow.FindControl("BtnAdd");
                        BtnAdd.Focus();
                        return;
                    }
                }
                //Check point
                //--t_purchase order detail and t_purchareinvoicedetail
                //string pono = TxtPoNo.Text;
                foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        string    HidCatagory0 = ((HiddenField)row.Cells[3].FindControl("HidCatagory0")).Value;
                        string    HidProduct0  = ((HiddenField)row.Cells[3].FindControl("HidProduct0")).Value;
                        DataTable DT           = ClsCheck.Get_PurchaseCheck(TxtPoNo.Text.Trim(), Convert.ToInt32(HidProduct0), Convert.ToInt32(HidCatagory0));
                        int       POQUANTITY   = Convert.ToInt32(((Label)row.Cells[2].FindControl("LblQuantity")).Text);

                        //int POQUANTITY = Convert.ToInt32(DT.Rows[0]["PO_QUANTITY"].ToString());
                        //int PURCHASEIN = Convert.ToInt32(DT.Rows[0]["PURCHASE_INVOICE"].ToString());
                        int TxtInQuantity = Convert.ToInt32(((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text);

                        if (POQUANTITY < TxtInQuantity)
                        {
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('GRN Quantity is greater than Purchase Quantity..');</script>", false);
                            return;
                        }
                    }
                }

                string POId = hidDetails_ID.Value;
                // string POId = ddlPONo.SelectedValue;
                DateTime PODATE   = Convert.ToDateTime(TxtPoDate.Text);
                string   ponumber = TxtPoNo.Text;

                int      GRNid;
                DateTime GRNdate     = DateTime.Now;
                string   totalAmount = "";
                GRNdate = Convert.ToDateTime(Txt_InvoiceDate.Text.Trim());
                //invoiceno = Txt_InvoiceNo.Text.Trim();
                totalAmount = Txt_SubTotal.Text.Trim();
                //showing alert if grn value is 0
                if (Txt_SubTotal.Text == "0" || Txt_SubTotal.Text == "0.0" || Txt_SubTotal.Text == "0.00")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('GRN Total  Amount can not be 0...');</script>", false);
                    return;
                }

                //taxid = Convert.ToInt32(DrpTaxType.SelectedItem.Value);
                result2 = ClsGoodsReceiptNote.InsertPurchaseGRN(out GRNid, Convert.ToInt32(POId), ponumber, PODATE,
                                                                GRNdate, Convert.ToDouble(totalAmount), Convert.ToInt32(Session["Id"]), TxtLorryRcptNum.Text.Trim(), txtVehicleNum.Text.Trim(), txtAWBNum.Text.Trim());
                if (result2)
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('GRN Saved Successfully...');</script>", false);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('GRN Insertion Failed...');</script>", false);
                }

                DataTable dtGRN = new DataTable();
                dtGRN.Columns.Add("State", typeof(string));
                dtGRN.Columns.Add("Location", typeof(string));
                dtGRN.Columns.Add("Category", typeof(string));
                dtGRN.Columns.Add("Product", typeof(string));
                dtGRN.Columns.Add("RecvdQuantity", typeof(string));

                foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        string LblSlno       = ((Label)row.Cells[0].FindControl("LblSlno")).Text;
                        Int64  HidPODetId    = Convert.ToInt32(((HiddenField)row.Cells[2].FindControl("HdfPODETID")).Value);
                        string lblCatagory   = ((Label)row.Cells[1].FindControl("lblCatagory")).Text;
                        Int32  HidCatagory0  = Convert.ToInt32(((HiddenField)row.Cells[2].FindControl("HidCatagory0")).Value);
                        string LblProduct    = ((Label)row.Cells[3].FindControl("LblProduct")).Text;
                        Int32  HidProduct0   = Convert.ToInt32(((HiddenField)row.Cells[4].FindControl("HidProduct0")).Value);
                        Int32  LblQuantity   = Convert.ToInt32(((Label)row.Cells[3].FindControl("LblQuantity")).Text);
                        double LblPrice      = Convert.ToDouble(((Label)row.Cells[3].FindControl("LblPrice")).Text);
                        double POTaxPrice    = Convert.ToDouble(((Label)row.Cells[3].FindControl("Lbltaxid")).Text);
                        double pototalamount = Convert.ToDouble(((Label)row.Cells[3].FindControl("LbltotalAmount")).Text);

                        string TxtInQuantity      = ((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text;
                        string TxtInPrice         = ((TextBox)row.Cells[4].FindControl("TxtInPrice")).Text;
                        double invoicetotalamount = Convert.ToDouble(((Label)row.Cells[3].FindControl("LblInvocietotalPrice")).Text);
                        string InvoiceTaxPrice    = ((TextBox)row.Cells[3].FindControl("txttaxid")).Text;

                        string loaction     = TxtShippingAddress.Text.Trim();
                        string MainLocation = TxtPoLocation.Text;
                        //added by sita for getting supplier ref number and date as per the new changes.

                        string SupRefNo = ((TextBox)row.FindControl("txtSupRefNo")).Text;
                        // ((TextBox)row.Cells[3].FindControl("txtSupRefNo")).Text;
                        string   TxtSupRefDate = ((TextBox)row.FindControl("txtSupRefDate")).Text;
                        DateTime SupRefDate    = System.DateTime.Now;
                        if (TxtSupRefDate.ToString() != string.Empty)
                        {
                            SupRefDate = Convert.ToDateTime(TxtSupRefDate);
                        }
                        //((TextBox)row.Cells[3].FindControl("txtSupRefDate")).Text;
                        if (TxtInQuantity != "0")
                        {
                            result1 = ClsGoodsReceiptNote.Insert_Po_GRN_Details(GRNid, Convert.ToInt32(POId), HidCatagory0, HidProduct0,
                                                                                LblQuantity, LblPrice, POTaxPrice, pototalamount, Convert.ToInt32(TxtInQuantity), Convert.ToDouble(TxtInPrice),
                                                                                InvoiceTaxPrice, invoicetotalamount, Convert.ToInt32(Session["Id"].ToString()), loaction, LblProduct, GRNdate, MainLocation,
                                                                                Convert.ToInt32(Session["int_LocationId"]), HidPODetId, SupRefNo, SupRefDate);

                            DataRow drGRN = dtGRN.NewRow();
                            drGRN["State"]         = TxtPoSupplierState.Text;
                            drGRN["Location"]      = TxtPoLocation.Text;
                            drGRN["Category"]      = lblCatagory;
                            drGRN["Product"]       = LblProduct;
                            drGRN["RecvdQuantity"] = TxtInQuantity;
                            dtGRN.Rows.Add(drGRN);
                        }
                    }
                }
                if (dtGRN.Rows.Count > 0)
                {
                    ClsSalesOrder objclsSo       = new ClsSalesOrder();
                    int           SentMailResult = objclsSo.Send_Mail_GRN_RecivedQuantity_Details(dtGRN);
                }

                // Txt_InvoiceNo.Text = "";
                Txt_InvoiceDate.Text  = "";
                Txt_SubTotal.Text     = "0.00";
                txtAWBNum.Text        = "";
                TxtInTotalAmount.Text = "0.00";
                GetGeneratePoDetails();
                Panel1.Visible = false; Panel2.Visible = true; tbldate.Visible = true;
            }
            else
            {
                //if (Txt_InvoiceNo.Text == "")
                //{
                //    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Enter Invoice Number.');</script>", false);
                //    Txt_InvoiceNo.Focus();
                //    return;

                //}
                if (Txt_InvoiceDate.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select GRN Date.');</script>", false);
                    Txt_InvoiceDate.Focus();
                    return;
                }

                //if (Txt_InvoiceDate.Text != "")
                //{
                //    DateTime PODate = Convert.ToDateTime(TxtPoDate.Text);
                //    DateTime PO_date = Convert.ToDateTime(PODate.ToString("dd/MM/yyyy"));
                //    DateTime InvoiceDate = Convert.ToDateTime(Txt_InvoiceDate.Text);
                //    DateTime Invoice_Date = Convert.ToDateTime(InvoiceDate.ToString("dd/MM/yyyy"));
                //    if (PO_date > Invoice_Date)
                //    {
                //        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Invoice Date Should be Greater Than PO Date.');</script>", false);
                //        TxtPoDate.Focus();
                //        return;
                //    }
                //}
                if (TxtLorryRcptNum.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Enter Lorry receipt number.');</script>", false);
                    TxtLorryRcptNum.Focus();
                    return;
                }
                // ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Fill Invoice Number and Invoice Date...');</script>", false);
            }
        }
        catch (Exception ex)
        {
        }
    }