public void btnSave_Click(object sender, EventArgs e)
    {
        OperationAreaService operationAreaService = new OperationAreaService();
        OperationArea        operationArea        = new ePower.DE.Domain.OperationArea();

        operationArea.AreaName       = txtAreaName.Text.Trim();
        operationArea.AuditReportId  = ReportId;
        operationArea.OperationHours = Convert.ToInt32(txtHours.Text.Trim());
        if (hdnId.Value != "" && Convert.ToInt32(hdnId.Value) > 0)
        {
            operationArea.Id = Convert.ToInt32(hdnId.Value);
            if (operationAreaService.Update(operationArea) != null)
            {
                BindOperation();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogOperation(" + 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
        {
            int i = operationAreaService.Insert(operationArea);
            if (i <= 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogOperation();", 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
            {
                BindOperation();
            }
        }
    }
예제 #2
0
 public OperationAreaBO(OperationArea operationareaDTO)
 {
     this.Id             = operationareaDTO.Id;
     this.AreaName       = operationareaDTO.AreaName;
     this.OperationHours = operationareaDTO.OperationHours;
     this.AuditReportId  = operationareaDTO.AuditReportId;
 }
    protected void rptOperation_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName.Equals("delete"))
        {
            OperationAreaService operationAreaService = new OperationAreaService();
            LinkButton           btnDelete            = (LinkButton)e.CommandSource;
            btnDelete.Visible = AllowEdit;
            long i = operationAreaService.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument));
            if (i > 0)
            {
                BindOperation();
            }
            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;
            OperationAreaService operationAreaService = new OperationAreaService();
            OperationArea        operationArea        = new ePower.DE.Domain.OperationArea();
            int OperationId = int.Parse(((LinkButton)e.CommandSource).CommandArgument);
            operationArea = operationAreaService.FindByKey(OperationId);
            if (operationArea != null)
            {
                try
                {
                    if (operationArea.OperationHours > 0)
                    {
                        txtHours.Text = operationArea.OperationHours.ToString();
                    }
                    txtAreaName.Text = operationArea.AreaName;
                }
                catch { }
                hdnId.Value = OperationId.ToString();
            }

            ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogOperation(" + hdnId.Value + ");", true);
        }
    }