private void calculateWorkHour()
        {
            // YYYY/MM/DD HH:MM:SS
            String   startDate   = CUtil.DateTimeToDateStringInternal(FromWorkDate).Substring(0, 10);
            String   startHHMMSS = String.Format("{0:D2}:{1:D2}:00", CUtil.StringToInt(FromWorkTimeHH), CUtil.StringToInt(FromWorkTimeMM));
            String   fromIntDate = String.Format("{0} {1}", startDate, startHHMMSS);
            DateTime startDtm    = CUtil.InternalDateToDate(fromIntDate);

            String   endDate    = CUtil.DateTimeToDateStringInternal(FromWorkDate).Substring(0, 10);
            String   endHHMMSS  = String.Format("{0:D2}:{1:D2}:00", CUtil.StringToInt(ToWorkTimeHH), CUtil.StringToInt(ToWorkTimeMM));
            String   endIntDate = String.Format("{0} {1}", endDate, endHHMMSS);
            DateTime endDtm     = CUtil.InternalDateToDate(endIntDate);

            TimeSpan span   = endDtm.Subtract(startDtm);
            double   hour   = span.TotalHours;
            double   adjust = CUtil.StringToDouble(WorkAdjustHour);

            if (hour >= 0)
            {
                WorkHour = hour.ToString();
                WorkAdjustedTotalHour = (hour - adjust).ToString();
            }
            else
            {
                WorkHour = "0.00";
                WorkAdjustedTotalHour = "0.00";
            }
        }
        private Boolean isNotEffectiveOrExpire(CProcessingResult res)
        {
            DateTime effDate     = package.EffectiveDate;
            DateTime expDate     = package.ExpireDate;
            String   effStr      = "";
            String   expStr      = "";
            String   currDateStr = CUtil.DateTimeToDateStringInternal(billDate);

            if (effDate != null)
            {
                effStr = CUtil.DateTimeToDateStringInternalMin(effDate);
                if (currDateStr.CompareTo(effStr) < 0)
                {
                    res.SetErrorCode("ERROR_PROMOTION_NOT_EFFECTIVE");
                    return(true);
                }
            }

            if (expDate != null)
            {
                expStr = CUtil.DateTimeToDateStringInternalMin(expDate);
                if (currDateStr.CompareTo(expStr) >= 0)
                {
                    res.SetErrorCode("ERROR_PROMOTION_IS_EXPIRE");
                    return(true);
                }
            }

            return(false);
        }
        private void cmdSave_Click(object sender, RoutedEventArgs e)
        {
            Boolean result = SaveToView();

            if (!result)
            {
                return;
            }

            String errCd = "";

            CUtil.EnableForm(false, this);
            if (billSim.BillSimulateID.Equals(""))
            {
                //Add mode
                billSim.DocumentType   = "1";
                billSim.DocumentStatus = "1";
                billSim.DocumentNo     = CUtil.DateTimeToDateStringInternal(DateTime.Now);
                billSim.SimulationFlag = "Y";
                CTable rtn = OnixWebServiceAPI.CreateBillSimulate(billSim.GetDbObject());
                if (rtn != null)
                {
                    billSim.SetDbObject(rtn);
                    billSim.InitSelectedItems();
                    billSim.IsModified = false;
                    CUtil.EnableForm(true, this);

                    CConfig.AddParam("LAST_BILL_SIMULATE_ID", billSim.BillSimulateID);
                    return;
                }

                errCd = "ERROR_USER_ADD";
            }
            else
            {
                //Edit mode
                CTable rtn = OnixWebServiceAPI.UpdateBillSimulate(billSim.GetDbObject());
                if (rtn != null)
                {
                    billSim.IsModified = false;
                    CUtil.EnableForm(true, this);

                    return;
                }

                errCd = "ERROR_USER_EDIT";
            }

            CUtil.EnableForm(true, this);

            //Error here
            CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), errCd, null);
            return;
        }
Beispiel #4
0
        private static void updateGui(DateTime t, UTimePicker ctrl)
        {
            if (t == null)
            {
                ctrl.txtHH.Text = "";
                ctrl.txtMM.Text = "";
            }
            else
            {
                String dtm = CUtil.DateTimeToDateStringInternal(t);
                //YYYY/MM/DD HH:MM:SS

                ctrl.txtHH.Text = dtm.Substring(11, 2);
                ctrl.txtMM.Text = dtm.Substring(14, 2);
            }
        }
Beispiel #5
0
        private DateTime constructTime()
        {
            int hh = CUtil.StringToInt(txtHH.Text);
            int mm = CUtil.StringToInt(txtMM.Text);
            int ss = 0;

            if (hh > 23)
            {
                hh = 23;
            }

            if (mm > 59)
            {
                mm = 59;
            }

            String curr = CUtil.DateTimeToDateStringInternal(DateTime.Now);

            String   intDate = String.Format("{0} {1:00}:{2:00}:{3:00}", curr.Substring(0, 10), hh, mm, ss);
            DateTime dtm     = CUtil.InternalDateToDate(intDate);

            return(dtm);
        }
        private void calculateOTHour()
        {
            // YYYY/MM/DD HH:MM:SS
            String   startDate   = CUtil.DateTimeToDateStringInternal(FromOtDate).Substring(0, 10);
            String   startHHMMSS = String.Format("{0:D2}:{1:D2}:00", CUtil.StringToInt(FromTimeHH), CUtil.StringToInt(FromTimeMM));
            String   fromIntDate = String.Format("{0} {1}", startDate, startHHMMSS);
            DateTime startDtm    = CUtil.InternalDateToDate(fromIntDate);

            String endDate   = CUtil.DateTimeToDateStringInternal(FromOtDate).Substring(0, 10); //เปลี่ยนมาใช้แบบภายในวันเดียวกัน
            String endHHMMSS = String.Format("{0:D2}:{1:D2}:00", CUtil.StringToInt(ToTimeHH), CUtil.StringToInt(ToTimeMM));

            if (endHHMMSS.CompareTo(startHHMMSS) < 0)
            {
                //End time less than start time
                //ให้ข้ามไปอีกหนึ่งวัน
                endDate = CUtil.DateTimeToDateStringInternal(FromOtDate.AddDays(1)).Substring(0, 10);
            }

            String   endIntDate = String.Format("{0} {1}", endDate, endHHMMSS);
            DateTime endDtm     = CUtil.InternalDateToDate(endIntDate);

            TimeSpan span   = endDtm.Subtract(startDtm);
            double   hour   = span.TotalHours;
            double   adjust = CUtil.StringToDouble(OtAdjustHour);

            if (hour >= 0)
            {
                OtHour = hour.ToString();
                OtAdjustedTotalHour = (hour - adjust).ToString();
            }
            else
            {
                OtHour = "0.00";
                OtAdjustedTotalHour = "0.00";
            }
        }
Beispiel #7
0
        private CTable verifyAndConstructObject()
        {
            foreach (CEntry en in entries)
            {
                UIElement elm   = en.ActualUI;
                String    value = "";

                if (en.EntryType == EntryType.ENTRY_DATE_MIN)
                {
                    UDatePicker dt = (UDatePicker)elm;
                    if (dt.SelectedDate == null)
                    {
                        value = "";
                    }
                    else
                    {
                        value = CUtil.DateTimeToDateStringInternalMin((DateTime)dt.SelectedDate);
                    }
                }
                else if (en.EntryType == EntryType.ENTRY_DATE_MAX)
                {
                    UDatePicker dt = (UDatePicker)elm;
                    if (dt.SelectedDate == null)
                    {
                        value = "";
                    }
                    else
                    {
                        value = CUtil.DateTimeToDateStringInternalMax((DateTime)dt.SelectedDate);
                    }
                }
                else if (en.EntryType == EntryType.ENTRY_MONTH_YEAR)
                {
                    UDateEntry dt = (UDateEntry)elm;
                    if (dt.SelectedDate == null)
                    {
                        value = "";
                    }
                    else
                    {
                        value = CUtil.DateTimeToDateStringInternal((DateTime)dt.SelectedDate);
                    }
                }
                else if (en.EntryType == EntryType.ENTRY_TEXT_BOX)
                {
                    TextBox txt = (TextBox)elm;

                    if (!CHelper.ValidateTextBox((Label)en.ActualLabel, txt, en.NullAllowed))
                    {
                        return(null);
                    }

                    value = txt.Text;
                }
                else if (en.EntryType == EntryType.ENTRY_CHECK_BOX)
                {
                    CheckBox cbx = (CheckBox)elm;

                    value = booleanToFlag((Boolean)cbx.IsChecked);
                }
                else if (en.EntryType == EntryType.ENTRY_COMBO_BOX)
                {
                    ComboBox cbo = (ComboBox)elm;

                    if (!CHelper.ValidateComboBox((Label)en.ActualLabel, cbo, en.NullAllowed))
                    {
                        return(null);
                    }

                    MBaseModel v = (MBaseModel)cbo.SelectedItem;
                    value = en.ObjectToIndexFunction(v);
                }

                String fld = en.FieldName;
                rptCfg.SetConfigValue(fld, value, "String", "");
            }

            if (!CHelper.ValidateComboBox(lblPaperType, cboPaperType, false))
            {
                return(null);
            }

            MMasterRef mr = (MMasterRef)cboPaperType.SelectedItem;

            rptCfg.SetConfigValue((String)cboPaperType.Tag, mr.MasterID, "Integer", "");


            if (radPotrait.IsChecked == true)
            {
                rptCfg.SetConfigValue((String)lblPaperType.Tag, (String)radPotrait.Tag, "String", "");
            }
            else if (radLandScape.IsChecked == true)
            {
                rptCfg.SetConfigValue((String)lblPaperType.Tag, (String)radLandScape.Tag, "String", "");
            }

            if (cbxPageRange.IsChecked == true)
            {
                paginator.isPageRange = true;

                if (!CHelper.ValidateTextBox(lblFromPage, txtFromPage, false, InputDataType.InputTypeZeroPossitiveInt))
                {
                    return(null);
                }
                paginator.fromPage = CUtil.StringToInt(txtFromPage.Text);

                if (!CHelper.ValidateTextBox(lblToPage, txtToPage, false, InputDataType.InputTypeZeroPossitiveInt))
                {
                    return(null);
                }
                paginator.toPage = CUtil.StringToInt(txtToPage.Text);

                if (paginator.toPage < paginator.fromPage)
                {
                    CHelper.ShowErorMessage("", "ERROR_PAGE_RANGE", null);
                    txtFromPage.Focus();

                    return(null);
                }
            }

            if (!CHelper.ValidateTextBox(lblMarginLeft, txtLeft, false, InputDataType.InputTypeZeroPossitiveDecimal))
            {
                return(null);
            }
            if (!CHelper.ValidateTextBox(lblMarginTop, txtTop, false, InputDataType.InputTypeZeroPossitiveDecimal))
            {
                return(null);
            }
            if (!CHelper.ValidateTextBox(lblMarginRight, txtRight, false, InputDataType.InputTypeZeroPossitiveDecimal))
            {
                return(null);
            }
            if (!CHelper.ValidateTextBox(lblMarginBottom, txtBottom, false, InputDataType.InputTypeZeroPossitiveDecimal))
            {
                return(null);
            }

            rptCfg.SetConfigValue((String)txtFromPage.Tag, txtFromPage.Text, "String", "");
            rptCfg.SetConfigValue((String)txtToPage.Tag, txtToPage.Text, "String", "");
            rptCfg.SetConfigValue((String)txtLeft.Tag, txtLeft.Text, "String", "");
            rptCfg.SetConfigValue((String)txtTop.Tag, txtTop.Text, "String", "");
            rptCfg.SetConfigValue((String)txtRight.Tag, txtRight.Text, "String", "");
            rptCfg.SetConfigValue((String)txtBottom.Tag, txtBottom.Text, "String", "");
            CUtil.EnableForm(false, this);
            CReportConfigs.SaveReportConfig(null, rptCfg);
            CUtil.EnableForm(true, this);

            CTable tb = rptCfg.GetParamObject();

            return(tb);
        }