예제 #1
0
 public void btnSaveDevice_Click(object sender, EventArgs e)
 {
     try
     {
         PlanTB        plantb        = new PlanTB();
         PlanTBService plantbservice = new PlanTBService();
         if (ddlCacThucLD.SelectedIndex > 0)
         {
             plantb.CachLapDat = ddlCacThucLD.SelectedValue;
         }
         plantb.EnterpriseId = Convert.ToInt32(memVal.OrgId);
         plantb.NameTB       = txtTenTB.Text;
         plantb.TinhNang     = txtTinhNangTB.Text;
         plantb.LyDo         = txtlydoTB.Text;
         plantb.Nam          = (ReportYear + 1);//Convert.ToInt32(txtnamTB.Text);
         if (ddlCamKetTB.SelectedIndex > 0)
         {
             plantb.CamKet = ddlCamKetTB.SelectedValue;
         }
         plantb.KhaNang    = txtKhaNangTB.Text.Trim();
         plantb.IdPlan     = ReportId;
         plantb.IsFiveYear = false;
         plantb.IsPlan     = true;
         plantb.IsNew      = false;
         if (hddkhTB.Value != "" && Convert.ToInt32(hddkhTB.Value) > 0)
         {
             plantb.Id = Convert.ToInt32(hddkhTB.Value);
             if (plantbservice.Update(plantb) != null)
             {
                 BindThietBi();
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công!');", true);
                 ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogDevicePlanOne(" + hddkhTB.Value + ");", true);
             }
         }
         else
         {
             int i = plantbservice.Insert(plantb);
             if (i > 0)
             {
                 BindThietBi();
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "showx", "alert('Cập nhật không thành công!');", true);
                 ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogDevicePlanOne(0);", true);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
 public void btnSaveAddDevice_Click(object sender, EventArgs e)
 {
     try
     {
         PlanTB        plantb        = new PlanTB();
         PlanTBService plantbservice = new PlanTBService();
         if (hddkhTB.Value != "")
         {
             plantb = plantbservice.FindByKey(Convert.ToInt32(hddkhTB.Value));
             if (ddlCacThucLDBS.SelectedIndex > 0)
             {
                 plantb.CachLapDat = ddlCacThucLDBS.SelectedValue;
             }
             plantb.EnterpriseId = m_UserValidation.OrgId;
             plantb.NameTB       = txtTenTietBiBS.Text;
             plantb.TinhNang     = txtMoTaTinhNangBS.Text;
             if (cbxThucHien.Checked)
             {
                 plantb.LyDoLapDat = txtLyDoKhongThucHien.Text;
             }
             else
             {
                 plantb.LyDo = txtLyDoKhongThucHien.Text;
             }
             plantb.Nam        = ReportYear;
             plantb.IsExecuted = cbxThucHien.Checked;
             plantb.IdPlan     = ReportId;
             plantb.IsFiveYear = false;
             plantb.IsPlan     = false;
             plantb.IsNew      = false;
             int i = plantbservice.Update(plantb).Id;
             if (i > 0)
             {
                 BindResultTB();
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "showkhd", "updateiaiphapTB();", true);
                 ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công!');", true);
             }
         }
         else
         {
             plantb.EnterpriseId = m_UserValidation.OrgId;
             if (ddlCacThucLDBS.SelectedIndex > 0)
             {
                 plantb.CachLapDat = ddlCacThucLDBS.SelectedValue;
             }
             plantb.NameTB     = txtTenTietBiBS.Text;
             plantb.TinhNang   = txtMoTaTinhNangBS.Text;
             plantb.Nam        = ReportYear;
             plantb.IsExecuted = cbxThucHien.Checked;
             if (cbxThucHien.Checked)
             {
                 plantb.LyDoLapDat = txtLyDoKhongThucHien.Text;
             }
             else
             {
                 plantb.LyDo = txtLyDoKhongThucHien.Text;
             }
             plantb.IsNew      = true;
             plantb.IsFiveYear = false;
             plantb.IsPlan     = false;
             plantb.IdPlan     = ReportId;
             int i = plantbservice.Insert(plantb);
             if (i > 0)
             {
                 BindResultTB();
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "showkhd", "updateiaiphapTB();", true);
                 ScriptManager.RegisterStartupScript(this, GetType(), "showx", "alert('Cập nhật không thành công!');", true);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #3
0
 public void btnSaveDevice_Click(object sender, EventArgs e)
 {
     try
     {
         PlanTB        plantb        = new PlanTB();
         PlanTBService plantbservice = new PlanTBService();
         if (hddkhTB.Value != "")
         {
             plantb = plantbservice.FindByKey(Convert.ToInt32(hddkhTB.Value));
             if (ddlCacThucLD.SelectedIndex > 0)
             {
                 plantb.CachLapDat = ddlCacThucLD.SelectedValue;
             }
             plantb.EnterpriseId = m_UserValidation.OrgId;
             plantb.NameTB       = txtTenTB.Text;
             plantb.TinhNang     = txtTinhNangTB.Text;
             plantb.LyDo         = txtlydoTB.Text;
             plantb.Nam          = Convert.ToInt32(txtnamTB.Text);
             if (ddlKhaNangTB.SelectedIndex > 0)
             {
                 plantb.KhaNang = ddlKhaNangTB.SelectedValue;
             }
             plantb.CamKet     = txtCamKetTB.Text.Trim();
             plantb.IdPlan     = ReportId;
             plantb.IsFiveYear = false;
             plantb.IsPlan     = true;
             plantb.IsNew      = false;
             int i = plantbservice.Update(plantb).Id;
             if (i > 0)
             {
                 BindThietBi();
                 ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "showgiaiphapTB('1');", true);
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công!');", true);
             }
         }
         else
         {
             //plantb.CamKet = txtMucCamKetTB.Text;
             if (ddlCacThucLD.SelectedIndex > 0)
             {
                 plantb.CachLapDat = ddlCacThucLD.SelectedValue;
             }
             plantb.EnterpriseId = m_UserValidation.OrgId;
             plantb.NameTB       = txtTenTB.Text;
             plantb.TinhNang     = txtTinhNangTB.Text;
             plantb.LyDo         = txtlydoTB.Text;
             plantb.Nam          = Convert.ToInt32(txtnamTB.Text);
             if (ddlKhaNangTB.SelectedIndex > 0)
             {
                 plantb.KhaNang = ddlKhaNangTB.SelectedValue;
             }
             plantb.CamKet     = txtCamKetTB.Text.Trim();
             plantb.IsFiveYear = false;
             plantb.IsPlan     = true;
             plantb.IsNew      = false;
             plantb.IdPlan     = ReportId;
             int i = plantbservice.Insert(plantb);
             if (i > 0)
             {
                 BindThietBi();
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "showgiaiphapTB('1');", true);
                 ScriptManager.RegisterStartupScript(this, GetType(), "showx", "alert('Cập nhật không thành công!');", true);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }