Example #1
0
 private void SaveData(bool showConfirmMsg = true)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (ValidateBeforeSave())
         {
             if (!showConfirmMsg || rMessageBox.ShowConfirmation(this, MessageCode.CFM0001) == DialogResult.Yes)
             {
                 int ID = vmRpt.SaveWorkPlaceAir(wpaResult);
                 rMessageBox.ShowInfomation(this, MessageCode.INF0002);
                 this.IsDataChange = true;
                 wpaResult         = vmRpt.GetWorkPlaceAir(ID);
                 mode = ScreenMode.Edit;
                 RetriveData();
             }
         }
     }
     catch (Exception ex)
     {
         rMessageBox.ShowException(this, ex);
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Example #2
0
 private void CancelData(bool isCancel)
 {
     try
     {
         string msg;
         if (isCancel)
         {
             msg = MessageCode.CFM0003;
         }
         else
         {
             msg = MessageCode.CFM0004;
         }
         if (rMessageBox.ShowConfirmation(this, msg) == DialogResult.Yes)
         {
             vmRpt.CancelWorkPlaceAir(wpaResult, isCancel);
             if (isCancel)
             {
                 rMessageBox.ShowInfomation(this, MessageCode.INF0004);
             }
             else
             {
                 rMessageBox.ShowInfomation(this, MessageCode.INF0005);
             }
             this.IsDataChange = true;
             wpaResult         = vmRpt.GetWorkPlaceAir(wpaResult.ID);
             RetriveData();
         }
     }
     catch (Exception ex)
     {
         rMessageBox.ShowException(this, ex);
     }
 }
Example #3
0
 public RPT002_WorkPlaceAirQualityEntry(int ID, bool isCopy = false)
 {
     InitializeComponent();
     wpaResult = vmRpt.GetWorkPlaceAir(ID);
     if (isCopy)
     {
         mode = ScreenMode.Add;
     }
     else
     {
         mode = ScreenMode.Edit;
     }
 }
 public RPT002_WorkPlaceAirQuality_Detail_Dialog(RPT002_WorkPlaceAirDTO data)
 {
     try
     {
         InitializeComponent();
         this.result = data;
         this.InitialScreen();
     }
     catch (Exception ex)
     {
         rMessageBox.ShowException(this, ex);
     }
 }
Example #5
0
        public RPT002_WorkPlaceAirDTO GetWorkPlaceAir(int ID)
        {
            var result = service.GetWorkPlaceAir(new RPT002_WorkPlaceAir_Criteria
            {
                ID = ID,
                SHOW_DELETE_RECORD = true,
            }).FirstOrDefault();

            if (result == null)
            {
                result = new sp_RPT002_GetWorkPlaceAir_Result();
            }
            RPT002_WorkPlaceAirDTO wpaDTO = mapper.Map <sp_RPT002_GetWorkPlaceAir_Result, RPT002_WorkPlaceAirDTO>(result);

            wpaDTO.Detail = service.GetWorkPlaceAirDt(ID);
            wpaDTO.User   = service.GetWorkPlaceAirUser(ID);
            return(wpaDTO);
        }
Example #6
0
 public void CancelWorkPlaceAir(RPT002_WorkPlaceAirDTO data, bool IS_CANCEL)
 {
     service.SaveWorkPlaceAir(data, IS_CANCEL);
 }
Example #7
0
 public int SaveWorkPlaceAir(RPT002_WorkPlaceAirDTO data)
 {
     return(service.SaveWorkPlaceAir(data, false));
 }
Example #8
0
        private void RetriveData()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                systemConfigResult = vmSys.GetSystemConfig();

                if (mode == ScreenMode.Add)
                {
                    if (wpaResult == null)
                    {
                        wpaResult                     = new RPT002_WorkPlaceAirDTO();
                        wpaResult.IS_WA               = true;
                        wpaResult.IS_AWA              = false;
                        wpaResult.REPORT_DATE         = DateTime.Now;
                        wpaResult.CRT_DATE            = DateTime.Now;
                        wpaResult.REGISTRATION_ID     = systemConfigResult.DEFAULT_REPORT_WPA_REGISTRATION_ID;
                        wpaResult.REGISTRATION_NAME   = systemConfigResult.DEFAULT_REPORT_WPA_REGISTRATION_NAME;
                        wpaResult.LAB_SUPERVISOR_ID   = systemConfigResult.DEFAULT_REPORT_WPA_LAB_SUPERVISOR_ID;
                        wpaResult.LAB_SUPERVISOR_NAME = systemConfigResult.DEFAULT_REPORT_WPA_LAB_SUPERVISOR_NAME;
                        wpaResult.AGENT_FLAG          = true;
                        wpaResult.SHOW_LV3_EACH_PAGE  = true;
                        wpaResult.SHOW_LV3_CONT       = true;
                        wpaResult.SHOW_LV2_CONT       = false;
                        this.ToolBarSwitch            = "2122222222";
                    }
                    else
                    {
                        wpaResult.ID                  = 0;
                        wpaResult.IS_WA               = true;
                        wpaResult.IS_AWA              = false;
                        wpaResult.ANALYSYS_NO         = null;
                        wpaResult.JOB_NO              = null;
                        wpaResult.CRT_ID              = null;
                        wpaResult.CRT_DATE            = DateTime.Now;
                        wpaResult.CRT_MACHINE         = null;
                        wpaResult.CRT_NAME            = null;
                        wpaResult.UPD_ID              = null;
                        wpaResult.UPD_DATE            = null;
                        wpaResult.UPD_MACHINE         = null;
                        wpaResult.UPD_NAME            = null;
                        wpaResult.DEL_ID              = null;
                        wpaResult.DEL_DATE            = null;
                        wpaResult.DEL_MACHINE         = null;
                        wpaResult.DEL_NAME            = null;
                        wpaResult.REGISTRATION_ID     = systemConfigResult.DEFAULT_REPORT_WPA_REGISTRATION_ID;
                        wpaResult.REGISTRATION_NAME   = systemConfigResult.DEFAULT_REPORT_WPA_REGISTRATION_NAME;
                        wpaResult.LAB_SUPERVISOR_ID   = systemConfigResult.DEFAULT_REPORT_WPA_LAB_SUPERVISOR_ID;
                        wpaResult.LAB_SUPERVISOR_NAME = systemConfigResult.DEFAULT_REPORT_WPA_LAB_SUPERVISOR_NAME;
                        wpaResult.AGENT_FLAG          = true;
                        wpaResult.AGENT_NAME          = null;
                        wpaResult.SHOW_LV3_EACH_PAGE  = true;
                        wpaResult.SHOW_LV3_CONT       = true;
                        wpaResult.SHOW_LV2_CONT       = false;
                        this.ToolBarSwitch            = "2122222222";
                    }
                }
                else if (wpaResult.DEL_ID.IsNull())
                {
                    this.ToolBarSwitch = "2122112102";
                }
                else
                {
                    this.ToolBarSwitch = "2022002012";
                }


                CtrlUtil.EnableControls(!wpaResult.Is_Canceled, txtCustomer, txtCustomerAddr, txtProject, txtProjectAddr, dtReceivedDate, dtAnalyticalDate, dtAnalyticalDateTo, chkShowLv3EachPage, chkShowLv3Cont, chkShowLv2Cont);

                CtrlUtil.EnableControls(OISDataInfo.UserInfomation.GROUP_ID == 3 && !wpaResult.Is_Canceled, txtRegistration, txtLabSupervisor);

                this.SetDataToControl();
            }
            catch (Exception ex)
            {
                rMessageBox.ShowException(this, ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Example #9
0
 public RPT002_WorkPlaceAirQualityEntry()
 {
     InitializeComponent();
     wpaResult = vmRpt.GetWorkPlaceAir(0);
     mode      = ScreenMode.Add;
 }
Example #10
0
 public int SaveWorkPlaceAir(RPT002_WorkPlaceAirDTO data, bool IS_CANCEL)
 {
     try
     {
         int ID = 0;
         using (OIS_RPTEntities ct = new OIS_RPTEntities())
             using (TransactionScope trans = new TransactionScope())
             {
                 ID = ct.sp_RPT002_SaveWorkPlaceAir(data.ID,
                                                    data.REPORT_DATE,
                                                    data.REPORT_TYPE,
                                                    data.ANALYSYS_NO,
                                                    data.CUSTOMER_ID,
                                                    data.CUSTOMER_ADDR,
                                                    data.CUSTOMER_PROJECT_ID,
                                                    data.CUSTOMER_PROJECT_ADDR,
                                                    data.RECEIVED_DATE,
                                                    data.ANALYTICAL_DATE_FROM,
                                                    data.ANALYTICAL_DATE_TO,
                                                    data.ANALYSIS_ID,
                                                    data.JOB_NO,
                                                    data.SAMPLING_BY,
                                                    data.REGISTRATION_ID,
                                                    data.LAB_SUPERVISOR_ID,
                                                    data.AGENT_FLAG,
                                                    data.AGENT_NAME,
                                                    data.SHOW_LV3_EACH_PAGE,
                                                    data.SHOW_LV3_CONT,
                                                    data.SHOW_LV2_CONT,
                                                    data.SHOW_PROJECT_ADDR,
                                                    OISDataInfo.UserInfomation.USER_ID,
                                                    IS_CANCEL).FirstOrDefault().GetValueOrDefault();
                 if (data.Detail != null)
                 {
                     foreach (DataRow dr in data.Detail.Rows)
                     {
                         ct.sp_RPT002_SaveWorkPlaceAirDt(dr.Field <int?>("ID"),
                                                         ID,
                                                         null,
                                                         dr.Field <string>("LOC_NAME"),
                                                         dr.Field <string>("LOC_NAME_LV2"),
                                                         dr.Field <string>("LOC_NAME_LV3"),
                                                         dr.Field <DateTime>("SAMPLING_DATE"),
                                                         dr.Field <int>("PARAMETER_ID"),
                                                         dr.Field <TimeSpan>("SAMPLING_TIME"),
                                                         dr.Field <decimal?>("AIR_FLOW"),
                                                         dr.Field <int>("SAMPLING_MINS"),
                                                         dr.Field <decimal?>("AIR_VOLUME"),
                                                         dr.Field <decimal?>("RESULT_VALUE"),
                                                         dr.Field <bool>("LESS_RESULT_VALUE"),
                                                         dr.Field <int>("UNIT_ID"),
                                                         dr.Field <decimal?>("STANDARD_THAI"),
                                                         dr.Field <decimal?>("STANDARD_ACGIH"),
                                                         dr.Field <bool>("CEILING_LIMIT"),
                                                         dr.Field <bool>("WAIT_RESULT"),
                                                         dr.Field <string>("REMARK"),
                                                         OISDataInfo.UserInfomation.USER_ID,
                                                         false);
                     }
                 }
                 string sql = "";
                 if (data.User != null)
                 {
                     foreach (DataRow dr in data.User.Rows)
                     {
                         if (sql.Length > 0)
                         {
                             sql = sql + Environment.NewLine;
                         }
                         sql = sql + string.Format("INSERT INTO TBR_WORK_PLACE_AIR_USER VALUES ({0}, '{1}');", ID, dr.Field <string>("SAMPLING_BY"));
                     }
                 }
                 if (sql.Length > 0)
                 {
                     ct.Database.ExecuteSqlCommand(sql);
                 }
                 trans.Complete();
             }
         return(ID);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }