public ElectricMotors Update(ElectricMotors obj)
        {
            ElectricMotorsBO electricmotorsBO = new ElectricMotorsBO(obj);

            electricmotorsDao.Update(electricmotorsBO);
            return(obj);
        }
示例#2
0
    public void btnSaveE_Click(object sender, EventArgs e)
    {
        ElectricMotorsService productCapacityService = new ElectricMotorsService();
        ElectricMotors        productCapacity        = new ElectricMotors();

        productCapacity.ElectricMotorsName = txtDeviceNameE.Text.Trim();
        if (txtQuantityE.Text.Trim() != "")
        {
            productCapacity.Quantity = Convert.ToInt32(txtQuantityE.Text.Trim());
        }
        if (txtHoursE.Text.Trim() != "")
        {
            productCapacity.OperationHours = Convert.ToInt32(txtHoursE.Text.Trim());
        }
        if (txtCapacityE.Text.Trim() != "")
        {
            productCapacity.Capacity = Convert.ToDecimal(txtCapacityE.Text.Trim());
        }
        if (txtCapacityUse.Text.Trim() != "")
        {
            productCapacity.CapacityUsed = Convert.ToDecimal(txtCapacityUse.Text.Trim());
        }
        productCapacity.AuditReportId = ReportId;

        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", "ShowDialogElectricMotor(" + 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
        {
            BindElectricMotors();
        }
    }
示例#3
0
 protected void rptElectricMotors_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("delete"))
     {
         ElectricMotorsService productCapacityService = new ElectricMotorsService();
         long i = productCapacityService.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument));
         if (i > 0)
         {
             BindElectricMotors();
         }
         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"))
     {
         ElectricMotors        productCapacity        = new ElectricMotors();
         ElectricMotorsService productCapacityService = new ElectricMotorsService();
         int ProductCapacityId = int.Parse(((LinkButton)e.CommandSource).CommandArgument);
         productCapacity = productCapacityService.FindByKey(ProductCapacityId);
         if (productCapacity != null)
         {
             txtDeviceNameE.Text = productCapacity.ElectricMotorsName;
             if (productCapacity.Quantity > 0)
             {
                 txtQuantityE.Text = productCapacity.Quantity.ToString();
             }
             if (productCapacity.Capacity > 0)
             {
                 txtCapacityE.Text = productCapacity.Capacity.ToString();
             }
             if (productCapacity.CapacityUsed > 0)
             {
                 txtCapacityUse.Text = productCapacity.CapacityUsed.ToString();
             }
             if (productCapacity.OperationHours > 0)
             {
                 txtHoursE.Text = productCapacity.OperationHours.ToString();
             }
         }
         hdnId.Value = ProductCapacityId.ToString();
         ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogElectricMotor(" + hdnId.Value + ");", true);
     }
 }
        public int Insert(ElectricMotors obj)
        {
            ElectricMotorsBO electricmotorsBO = new ElectricMotorsBO(obj);

            return(electricmotorsDao.Insert(electricmotorsBO));
        }