コード例 #1
0
    protected void lb_Modify_Click(object sender, EventArgs e)
    {
        Boolean           flag           = false;
        NetworkCredential NetCredentials = new NetworkCredential();

        NetCredentials.UserName = ConfigurationManager.AppSettings["UserName"];
        NetCredentials.Password = ConfigurationManager.AppSettings["Password"];

        try
        {
            foreach (RepeaterItem item in rpt_Cart.Items)
            {
                HiddenField  hf_ProductCode        = (HiddenField)item.FindControl("hf_ProductCode");
                TextBox      tb_ProductName        = (TextBox)item.FindControl("tb_ProductName");
                HiddenField  dd_UOM                = (HiddenField)item.FindControl("hf_UOM");
                TextBox      tb_Qty                = (TextBox)item.FindControl("tb_Qty");
                TextBox      tb_Price              = (TextBox)item.FindControl("tb_Price");
                TextBox      tb_CPrice             = (TextBox)item.FindControl("txt_Customerprice");
                DropDownList dd_Variant            = (DropDownList)item.FindControl("dd_Variant");
                TextBox      tb_Remark             = (TextBox)item.FindControl("tb_Remark");
                TextBox      tb_Discount           = (TextBox)item.FindControl("tb_Discount");
                TextBox      tb_Total              = (TextBox)item.FindControl("tb_Total");
                HiddenField  hf_QuantityShipped    = (HiddenField)item.FindControl("hf_QuantityShipped");
                HiddenField  hf_OutStandingQty     = (HiddenField)item.FindControl("hf_OutStandingQty");
                HiddenField  hf_CustomerPriceGroup = (HiddenField)item.FindControl("hf_CustomerPriceGroup") as HiddenField;

                if (Convert.ToDecimal(hf_QuantityShipped.Value) > 0)
                {
                    if (tb_Qty.Text != string.Empty)
                    {
                        string  Qty = Convert.ToString(VaraintQtyforProduct(hf_ProductCode.Value, dd_Variant.SelectedItem.Text, hf_CustomerPriceGroup.Value));
                        decimal mod = Convert.ToDecimal(tb_Qty.Text) % Convert.ToDecimal(Qty);

                        if (mod > 0)
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please enter quantity in multiple of variant code.');", true);
                            flag = false;
                            tb_Qty.Focus();
                            tb_Qty.Text = string.Empty;
                            break;
                        }
                        else
                        {
                            Web_Order_Mail objser = new Web_Order_Mail();
                            objser.UseDefaultCredentials = true;
                            objser.Credentials           = NetCredentials;
                            objser.UpdateBanketSalesLineQty(Convert.ToString(Request["BlanketOrderNo"]), Convert.ToInt32(Request["LineNo"]), Convert.ToDecimal(tb_Qty.Text));
                            objser = null;

                            Web_Order_Mail objser1 = new Web_Order_Mail();
                            objser1.UseDefaultCredentials = true;
                            objser1.Credentials           = NetCredentials;
                            objser1.UpdateSalesLineQty(Convert.ToString(Request["OrderNo"]), Convert.ToInt32(Request["LineNo"]), Convert.ToDecimal(tb_Qty.Text));
                            objser1 = null;
                            flag    = true;
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please enter quantity.');", true);
                        flag = false;
                        tb_Qty.Focus();
                        break;
                    }
                }
                else
                {
                    decimal amt         = Convert.ToDecimal(Convert.ToDecimal(tb_Qty.Text) * Convert.ToDecimal(tb_CPrice.Text));
                    decimal totalamount = Convert.ToDecimal(amt);
                    if (tb_Qty.Text != null && tb_CPrice.Text != null)
                    {
                        if (Convert.ToDecimal(tb_CPrice.Text) < Convert.ToDecimal(tb_Price.Text))
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please enter price above base price.');", true);
                            flag = false;
                            tb_CPrice.Focus();
                            tb_CPrice.Text = string.Empty;
                            break;
                        }
                        else
                        {
                            string  Qty = Convert.ToString(VaraintQtyforProduct(hf_ProductCode.Value, dd_Variant.SelectedItem.Text, hf_CustomerPriceGroup.Value));
                            decimal mod = Convert.ToDecimal(tb_Qty.Text) % Convert.ToDecimal(Qty);
                            if (mod > 0)
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please enter quantity in multiple of variant code.');", true);
                                flag = false;
                                tb_Qty.Focus();
                                tb_Qty.Text = string.Empty;
                                break;
                            }
                            else
                            {
                                decimal d = Convert.ToDecimal(tb_Price.Text) * 15 / 100;
                                d = Convert.ToDecimal(tb_Price.Text) + d;
                                if (Convert.ToDecimal(tb_CPrice.Text) >= d)
                                {
                                    ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript: fnShowMessage(); ", true);
                                    flag = false;
                                    tb_CPrice.Focus();
                                    tb_CPrice.Text = string.Empty;
                                    break;
                                }
                                else
                                {
                                    flag = true;
                                    //Update Blanket Order due to updating Qty in blanket Order as well as Sales Order
                                    Web_Order_Mail objser2 = new Web_Order_Mail();
                                    objser2.UseDefaultCredentials = true;
                                    objser2.Credentials           = NetCredentials;
                                    objser2.UpdateSalesLine(Convert.ToString(Request["BlanketOrderNo"]), Convert.ToInt32(Request["LineNo"]), hf_ProductCode.Value, dd_Variant.SelectedItem.Text, dd_UOM.Value, Convert.ToDecimal(tb_Qty.Text), Convert.ToDecimal(tb_CPrice.Text), tb_Remark.Text);
                                    objser2 = null;

                                    // Update SalesOrder Lines Details.
                                    Web_Order_Mail objser1 = new Web_Order_Mail();
                                    objser1.UseDefaultCredentials = true;
                                    objser1.Credentials           = NetCredentials;
                                    objser1.UpdateSalesLine(Convert.ToString(Request["OrderNo"]), Convert.ToInt32(Request["LineNo"]), hf_ProductCode.Value, dd_Variant.SelectedItem.Text, dd_UOM.Value, Convert.ToDecimal(tb_Qty.Text), Convert.ToDecimal(tb_CPrice.Text), tb_Remark.Text);
                                    objser1 = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        var message = new JavaScriptSerializer().Serialize("Quantity or Bill Price should not be blank or zero.");
                        var script  = string.Format("alert({0});", message);
                        ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
                    }
                }
                if (flag == false)
                {
                }
                else
                {
                    //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Record updated successfully.');window.location ='OrderModificationView.aspx';", true);
                    Response.Redirect("OrderModificationView.aspx?OrderNo=" + Request["OrderNo"].ToString() + "&BlanketOrderNo=" + Convert.ToString(Request["BlanketOrderNo"]) + "&PostingDate=" + Convert.ToString(Request.QueryString["PostingDate"]), false);
                }
            }
        }
        catch (Exception ex)
        {
            var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
            var script  = string.Format("alert({0});", message);
            ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
        }
    }
コード例 #2
0
    protected void lb_Modify_Click(object sender, EventArgs e)
    {
        Boolean           flag           = false;
        NetworkCredential NetCredentials = new NetworkCredential();

        NetCredentials.UserName = ConfigurationManager.AppSettings["UserName"];
        NetCredentials.Password = ConfigurationManager.AppSettings["Password"];
        try
        {
            foreach (RepeaterItem item in rpt_Cart.Items)
            {
                HiddenField  hf_ProductCode     = (HiddenField)item.FindControl("hf_ProductCode");
                TextBox      tb_ProductName     = (TextBox)item.FindControl("tb_ProductName");
                HiddenField  dd_UOM             = (HiddenField)item.FindControl("hf_UOM");
                TextBox      tb_Qty             = (TextBox)item.FindControl("tb_Qty");
                TextBox      txtSellingPrice    = (TextBox)item.FindControl("txtSellingPrice");
                DropDownList dd_Variant         = (DropDownList)item.FindControl("dd_Variant");
                TextBox      tb_Remark          = (TextBox)item.FindControl("tb_Remark");
                HiddenField  hf_QuantityShipped = (HiddenField)item.FindControl("hf_QuantityShipped");
                HiddenField  hf_OutStandingQty  = (HiddenField)item.FindControl("hf_OutStandingQty");

                HiddenField CustomerId            = (HiddenField)item.FindControl("hf_SelltoCustomerNo") as HiddenField;
                HiddenField ConsigneeId           = (HiddenField)item.FindControl("hf_ShiptoCode") as HiddenField;
                HiddenField hf_CustomerPriceGroup = (HiddenField)item.FindControl("hf_CustomerPriceGroup") as HiddenField;
                if (string.IsNullOrEmpty(ConsigneeId.Value))
                {
                    ConsigneeId.Value = CustomerId.Value;
                }


                string s = Convert.ToString(PriceforProduct(hf_ProductCode.Value, dd_Variant.SelectedItem.Text, hf_CustomerPriceGroup.Value, CustomerId.Value, ConsigneeId.Value));

                if (Convert.ToDecimal(hf_QuantityShipped.Value) > 0)
                {
                    if (tb_Qty.Text != "")
                    {
                        string  Qty = Convert.ToString(VaraintQtyforProduct(hf_ProductCode.Value, dd_Variant.SelectedItem.Text));
                        decimal mod = Convert.ToDecimal(tb_Qty.Text) % Convert.ToDecimal(Qty);

                        if (mod > 0)
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please enter quantity in multiple of variant code.');", true);
                            flag = false;
                            tb_Qty.Focus();
                            tb_Qty.Text = string.Empty;
                            break;
                        }
                        else
                        {
                            Web_Order_Mail objser = new Web_Order_Mail();
                            objser.UseDefaultCredentials = true;
                            objser.Credentials           = NetCredentials;
                            objser.UpdateBanketSalesLineQty(Convert.ToString(Request["BlanketOrderNo"]), Convert.ToInt32(Request["LineNo"]), Convert.ToDecimal(tb_Qty.Text));
                            objser = null;

                            Web_Order_Mail objser1 = new Web_Order_Mail();
                            objser1.UseDefaultCredentials = true;
                            objser1.Credentials           = NetCredentials;
                            objser1.UpdateSalesLineQty(Convert.ToString(Request["OrderNo"]), Convert.ToInt32(Request["LineNo"]), Convert.ToDecimal(tb_Qty.Text));
                            objser1 = null;
                            flag    = true;
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please enter quantity.');", true);
                        flag = false;
                        tb_Qty.Focus();
                        break;
                    }
                }
                else
                {
                    decimal amt                    = Convert.ToDecimal(Convert.ToDecimal(tb_Qty.Text) * Convert.ToDecimal(txtSellingPrice.Text));
                    decimal totalamount            = Convert.ToDecimal(amt);
                    string  ConsumerPrice          = Convert.ToString(ConsumerPriceforProduct(hf_ProductCode.Value, dd_Variant.SelectedItem.Text));
                    decimal ConsPriceIncPercentage = 0;
                    ConsPriceIncPercentage = Convert.ToDecimal(ConsumerPrice) + (Convert.ToDecimal(ConsumerPrice) * Convert.ToDecimal(ConfigurationManager.AppSettings["ConsumerPriceIncreasePercentage"]) / 100);

                    if (tb_Qty.Text != null && txtSellingPrice.Text != null)
                    {
                        if (Convert.ToDecimal(ConsPriceIncPercentage) > 0)
                        {
                            if (Convert.ToDecimal(txtSellingPrice.Text) > Convert.ToDecimal(ConsPriceIncPercentage))
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Bill Price exceeds permissible limit.');", true);
                                txtSellingPrice.Focus();
                                var script = String.Format("document.getElementById('{0}').select();", txtSellingPrice.ClientID);
                                ClientScript.RegisterStartupScript(GetType(), "focus", script, true);
                            }
                            else if (Convert.ToDecimal(txtSellingPrice.Text) < Convert.ToDecimal(s))
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Bill Price below permissible limit.');", true);
                                txtSellingPrice.Focus();
                                var script = String.Format("document.getElementById('{0}').select();", txtSellingPrice.ClientID);
                                ClientScript.RegisterStartupScript(GetType(), "focus", script, true);
                            }
                            else
                            {
                                string  Qty = Convert.ToString(VaraintQtyforProduct(hf_ProductCode.Value, dd_Variant.SelectedItem.Text));
                                decimal mod = Convert.ToDecimal(tb_Qty.Text) % Convert.ToDecimal(Qty);
                                if (mod > 0)
                                {
                                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please enter quantity in multiple of variant code.');", true);
                                    flag = false;
                                    tb_Qty.Focus();
                                    tb_Qty.Text = string.Empty;
                                    break;
                                }
                                else
                                {
                                    flag = true;
                                    //Update Blanket Order due to updating Qty in blanket Order as well as Sales Order
                                    Web_Order_Mail objser2 = new Web_Order_Mail();
                                    objser2.UseDefaultCredentials = true;
                                    objser2.Credentials           = NetCredentials;
                                    string st = dd_Variant.SelectedItem.Text;
                                    objser2.UpdateSalesLine(Convert.ToString(Request["BlanketOrderNo"]), Convert.ToInt32(Request["LineNo"]), hf_ProductCode.Value, dd_Variant.SelectedItem.Text, Convert.ToString(dd_UOM.Value), Convert.ToDecimal(tb_Qty.Text), Convert.ToDecimal(txtSellingPrice.Text), tb_Remark.Text);
                                    objser2 = null;

                                    // Update SalesOrder Lines Details.
                                    Web_Order_Mail objser1 = new Web_Order_Mail();
                                    objser1.UseDefaultCredentials = true;
                                    objser1.Credentials           = NetCredentials;
                                    objser1.UpdateSalesLine(Convert.ToString(Request["OrderNo"]), Convert.ToInt32(Request["LineNo"]), hf_ProductCode.Value, dd_Variant.SelectedItem.Text, Convert.ToString(dd_UOM.Value), Convert.ToDecimal(tb_Qty.Text), Convert.ToDecimal(txtSellingPrice.Text), tb_Remark.Text);
                                    objser1 = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        var message = new JavaScriptSerializer().Serialize("Quantity or Bill Price should not be blank or zero.");
                        var script  = string.Format("alert({0});", message);
                        ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
                    }
                }
                if (flag == false)
                {
                }
                else
                {
                    Response.Redirect("OrderModificationView.aspx?OrderNo=" + Request["OrderNo"].ToString() + "&BlanketOrderNo=" + Convert.ToString(Request["BlanketOrderNo"]) + "&PostingDate=" + Convert.ToString(Request.QueryString["PostingDate"]), false);
                }
            }
        }
        catch (Exception ex)
        {
            var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
            var script  = string.Format("alert({0});", message);
            ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
        }
    }