예제 #1
0
        public ProductCapacity Update(ProductCapacity obj)
        {
            ProductCapacityBO productcapacityBO = new ProductCapacityBO(obj);

            productcapacityDao.Update(productcapacityBO);
            return(obj);
        }
예제 #2
0
 protected void rptProductPlan_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("delete"))
     {
         ProductCapacityService rptbso    = new ProductCapacityService();
         LinkButton             btnDelete = (LinkButton)e.CommandSource;
         btnDelete.Visible = AllowEdit;
         long i = rptbso.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument));
         if (i > 0)
         {
             BindProductCapacityPlan();
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "alert('Xóa không thành không. Vui lòng thử lại');", true);
         }
     }
     else if (e.CommandName.Equals("edit"))
     {
         LinkButton btnEdit = (LinkButton)e.CommandSource;
         btnEdit.Visible = AllowEdit;
         ProductCapacity        productCapacity        = new ProductCapacity();
         ProductCapacityService productCapacityService = new ProductCapacityService();
         int ProductCapacityId = int.Parse(((LinkButton)e.CommandSource).CommandArgument);
         productCapacity = productCapacityService.FindByKey(ProductCapacityId);
         if (productCapacity != null)
         {
             try
             {
                 txtMaxQtyPlan.Text           = productCapacity.MaxQuantity.ToString();
                 txtQtyByDesignPlan.Text      = productCapacity.DesignQuantity.ToString();
                 txtRateOfCost.Text           = productCapacity.RateOfCost.ToString();
                 txtRateOfRevenue.Text        = productCapacity.RateOfRevenue.ToString();
                 ddlProductPlan.SelectedValue = productCapacity.ProductId.ToString();
                 //txtDoanhThuTheoSP.Text = productCapacity.DoanhThuTheoSP.ToString();
                 Product        product        = new Product();
                 ProductService productService = new ProductService();
                 product = productService.FindByKey(productCapacity.ProductId);
                 ltMeasurementPlan.Text = "(" + product.Measurement + ")";
             }
             catch { }
         }
         hdnId.Value = ProductCapacityId.ToString();
         ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "AddProductQtyPlan(" + hdnId.Value + ");", true);
     }
 }
예제 #3
0
        public int Insert(ProductCapacity obj)
        {
            ProductCapacityBO productcapacityBO = new ProductCapacityBO(obj);

            return(productcapacityDao.Insert(productcapacityBO));
        }
예제 #4
0
    public void btnSaveProductPlan_Click(object sender, EventArgs e)
    {
        ProductCapacityService productCapacityService = new ProductCapacityService();
        ProductCapacity        productCapacity        = new ProductCapacity();
        int _ProductId = Convert.ToInt32(ddlProductPlan.SelectedValue);

        if (txtQtyByDesignPlan.Text != "")
        {
            productCapacity.DesignQuantity = Convert.ToDecimal(txtQtyByDesignPlan.Text);
        }
        if (txtMaxQtyPlan.Text.Trim() != "")
        {
            productCapacity.MaxQuantity = Convert.ToDecimal(txtMaxQtyPlan.Text.Trim());
        }
        productCapacity.IsPlan = true;
        if (txtRateOfRevenue.Text.Trim() != "")
        {
            productCapacity.RateOfRevenue = Convert.ToDecimal(txtRateOfRevenue.Text.Trim());
        }
        if (txtRateOfCost.Text.Trim() != "")
        {
            productCapacity.RateOfCost = Convert.ToDecimal(txtRateOfCost.Text.Trim());
        }
        productCapacity.ProductId  = _ProductId;
        productCapacity.ReportId   = ReportId;
        productCapacity.ReportYear = ReportYear;

        ReportModels rp    = new ReportModels();
        var          check = rp.DE_ProductCapacity.FirstOrDefault(o => o.ReportId == ReportId && o.IsPlan == true && o.ProductId == _ProductId);

        if (check != null)
        {
            hdnId.Value = check.Id.ToString();
        }

        int i = 0;

        if (hdnId.Value != "" && Convert.ToInt32(hdnId.Value) > 0)
        {
            productCapacity.Id = Convert.ToInt32(hdnId.Value);
            productCapacity    = productCapacityService.Update(productCapacity);
            if (productCapacity != null)
            {
                i = 1;
            }
        }
        else
        {
            i = productCapacityService.Insert(productCapacity);
        }

        if (i <= 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "AddProductQtyPlan(" + hdnId.Value + ");", true);
            ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công. Vui lòng thử lại!');", true);
        }
        else
        {
            BindProductCapacityPlan();
        }
    }