示例#1
0
    protected void btnUpdateProductResult_Click(object sender, EventArgs e)
    {
        ReportModels rp = new ReportModels();

        if (rp.DE_ProductCapacity.Any(x => x.ReportId == ReportId && x.IsPlan == false)) //Update
        {
            var tempData = rp.DE_ProductCapacity.Where(x => x.ReportId == ReportId && x.IsPlan == false).ToList();

            foreach (RepeaterItem ri in rptProductResult.Items)
            {
                TextBox     txtMaxQuantity           = ri.FindControl("txtMaxQuantity") as TextBox;
                HiddenField hdProductId              = ri.FindControl("hdProductId") as HiddenField;
                TextBox     txtNangLucVanChuyenNguoi = ri.FindControl("txtNangLucVanChuyenNguoi") as TextBox;
                TextBox     txtNangLucVanChuyenHang  = ri.FindControl("txtNangLucVanChuyenHang") as TextBox;
                RadioButton radio1 = ri.FindControl("radio1") as RadioButton;
                RadioButton radio2 = ri.FindControl("radio2") as RadioButton;

                int     ProductId  = Convert.ToInt32(hdProductId.Value);
                var     pcInfo     = tempData.FirstOrDefault(x => x.ProductId == ProductId);
                decimal tmpDecimal = 0;
                if (decimal.TryParse(txtMaxQuantity.Text, style, culture, out tmpDecimal))
                {
                    pcInfo.MaxQuantity = tmpDecimal;
                }
                else
                {
                    pcInfo.MaxQuantity = 0;
                }

                if (radio1.Checked && txtNangLucVanChuyenNguoi.Text.Trim() != "")
                {
                    pcInfo.NangLucVanChuyenNguoi = Convert.ToDecimal(txtNangLucVanChuyenNguoi.Text.Trim(), culture);
                }

                if (radio2.Checked && txtNangLucVanChuyenHang.Text.Trim() != "")
                {
                    pcInfo.NangLucVanChuyenHang = Convert.ToDecimal(txtNangLucVanChuyenHang.Text.Trim(), culture);
                }
            }

            rp.SaveChanges();
        }
        else //Insert
        {
            foreach (RepeaterItem ri in rptProductResult.Items)
            {
                DE_ProductCapacity pcInfo                   = new DE_ProductCapacity();
                TextBox            txtMaxQuantity           = ri.FindControl("txtMaxQuantity") as TextBox;
                HiddenField        hdProductId              = ri.FindControl("hdProductId") as HiddenField;
                TextBox            txtNangLucVanChuyenNguoi = ri.FindControl("txtNangLucVanChuyenNguoi") as TextBox;
                TextBox            txtNangLucVanChuyenHang  = ri.FindControl("txtNangLucVanChuyenHang") as TextBox;
                RadioButton        radio1                   = ri.FindControl("radio1") as RadioButton;
                RadioButton        radio2                   = ri.FindControl("radio2") as RadioButton;

                int ProductId = Convert.ToInt32(hdProductId.Value);
                pcInfo.ProductId  = ProductId;
                pcInfo.ReportId   = ReportId;
                pcInfo.IsPlan     = false;
                pcInfo.ReportYear = ReportYear;

                decimal tmpDecimal = 0;
                if (decimal.TryParse(txtMaxQuantity.Text, style, culture, out tmpDecimal))
                {
                    pcInfo.MaxQuantity = tmpDecimal;
                }
                else
                {
                    pcInfo.MaxQuantity = 0;
                }

                if (radio1.Checked && txtNangLucVanChuyenNguoi.Text.Trim() != "")
                {
                    pcInfo.NangLucVanChuyenNguoi = Convert.ToDecimal(txtNangLucVanChuyenNguoi.Text.Trim(), culture);
                }
                else
                {
                    pcInfo.NangLucVanChuyenNguoi = 0;
                }

                if (radio2.Checked && txtNangLucVanChuyenHang.Text.Trim() != "")
                {
                    pcInfo.NangLucVanChuyenHang = Convert.ToDecimal(txtNangLucVanChuyenHang.Text.Trim(), culture);
                }
                else
                {
                    pcInfo.NangLucVanChuyenHang = 0;
                }

                rp.DE_ProductCapacity.Add(pcInfo);
            }
            rp.SaveChanges();
        }

        btnCancelProductResult_Click(sender, e);
    }
示例#2
0
    protected void btnAddProductNextResultUpdate_Click(object sender, EventArgs e)
    {
        ReportModels rp = new ReportModels();

        if (rp.DE_ProductCapacity.Any(x => x.ReportId == ReportId && x.IsPlan == true)) //Update
        {
            var tempData = rp.DE_ProductCapacity.Where(x => x.ReportId == ReportId && x.IsPlan == true).ToList();
            foreach (RepeaterItem ri in rptProductPlan.Items)
            {
                TextBox     txtMaxQuantity    = ri.FindControl("txtMaxQuantity") as TextBox;
                TextBox     txtDesignQuantity = ri.FindControl("txtDesignQuantity") as TextBox;
                HiddenField hdProductId       = ri.FindControl("hdProductId") as HiddenField;
                int         ProductId         = Convert.ToInt32(hdProductId.Value);
                var         pcInfo            = tempData.FirstOrDefault(x => x.ProductId == ProductId);
                decimal     tmpDecimal        = 0;

                if (decimal.TryParse(txtMaxQuantity.Text, style, culture, out tmpDecimal))
                {
                    pcInfo.MaxQuantity = tmpDecimal;
                }
                else
                {
                    pcInfo.MaxQuantity = 0;
                }

                if (decimal.TryParse(txtDesignQuantity.Text, style, culture, out tmpDecimal))
                {
                    pcInfo.DesignQuantity = tmpDecimal;
                }
                else
                {
                    pcInfo.DesignQuantity = 0;
                }
            }

            rp.SaveChanges();
        }
        else //Insert
        {
            foreach (RepeaterItem ri in rptProductPlan.Items)
            {
                DE_ProductCapacity pcInfo            = new DE_ProductCapacity();
                TextBox            txtMaxQuantity    = ri.FindControl("txtMaxQuantity") as TextBox;
                TextBox            txtDesignQuantity = ri.FindControl("txtDesignQuantity") as TextBox;
                HiddenField        hdProductId       = ri.FindControl("hdProductId") as HiddenField;
                int ProductId = Convert.ToInt32(hdProductId.Value);
                pcInfo.ProductId  = ProductId;
                pcInfo.ReportId   = ReportId;
                pcInfo.IsPlan     = true;
                pcInfo.ReportYear = ReportYear;

                decimal tmpDecimal = 0;
                if (decimal.TryParse(txtMaxQuantity.Text, style, culture, out tmpDecimal))
                {
                    pcInfo.MaxQuantity = tmpDecimal;
                }
                else
                {
                    pcInfo.MaxQuantity = 0;
                }

                if (decimal.TryParse(txtDesignQuantity.Text, style, culture, out tmpDecimal))
                {
                    pcInfo.DesignQuantity = tmpDecimal;
                }
                else
                {
                    pcInfo.DesignQuantity = 0;
                }

                rp.DE_ProductCapacity.Add(pcInfo);
            }
            rp.SaveChanges();
        }

        btnAddProductNextResultCancel_Click(sender, e);
    }
示例#3
0
    protected void btnUpdateProductResult_Click(object sender, EventArgs e)
    {
        ReportModels rp = new ReportModels();

        if (rp.DE_ProductCapacity.Any(x => x.ReportId == ReportId && x.IsPlan == false)) //Update
        {
            var tempData = rp.DE_ProductCapacity.Where(x => x.ReportId == ReportId && x.IsPlan == false).ToList();
            foreach (RepeaterItem ri in rptProductResult.Items)
            {
                HiddenField hdProductId = ri.FindControl("hdProductId") as HiddenField;
                int         ProductId   = Convert.ToInt32(hdProductId.Value);
                var         pcInfo      = tempData.FirstOrDefault(x => x.ProductId == ProductId);
                if (pcInfo == null)
                {
                    //Khởi tạo    pcInfo
                    pcInfo            = new DE_ProductCapacity();
                    pcInfo.ProductId  = ProductId;
                    pcInfo.ReportId   = ReportId;
                    pcInfo.IsPlan     = false;
                    pcInfo.ReportYear = ReportYear;
                    rp.DE_ProductCapacity.Add(pcInfo);
                    TextBox txtDataReport1415 = ri.FindControl("txtDataReport1415") as TextBox;
                    pcInfo.DataReport1415 = txtDataReport1415.Text.Trim();
                }
                else
                {
                    TextBox txtDataReport1415 = ri.FindControl("txtDataReport1415") as TextBox;
                    pcInfo.DataReport1415 = txtDataReport1415.Text.Trim();
                }
            }

            rp.SaveChanges();
        }
        else //Insert
        {
            foreach (RepeaterItem ri in rptProductResult.Items)
            {
                DE_ProductCapacity pcInfo            = new DE_ProductCapacity();
                TextBox            txtDataReport1415 = ri.FindControl("txtDataReport1415") as TextBox;
                HiddenField        hdProductId       = ri.FindControl("hdProductId") as HiddenField;
                int ProductId = Convert.ToInt32(hdProductId.Value);
                pcInfo.ProductId      = ProductId;
                pcInfo.ReportId       = ReportId;
                pcInfo.IsPlan         = false;
                pcInfo.ReportYear     = ReportYear;
                pcInfo.DataReport1415 = txtDataReport1415.Text.Trim();
                rp.DE_ProductCapacity.Add(pcInfo);
            }
            rp.SaveChanges();
        }

        btnAddProductResult.Visible    = true;
        btnUpdateProductResult.Visible = false;
        btnCancelProductResult.Visible = false;

        foreach (RepeaterItem ri in rptProductResult.Items)
        {
            TextBox txtDataReport1415 = ri.FindControl("txtDataReport1415") as TextBox;
            txtDataReport1415.ReadOnly = true;
        }
    }