Exemple #1
0
        private void LoadDefaultPeriod(bool LoadCurrentPeriod, bool LoadDefaultYearMonth)
        {
            InventoryPeriodBIZ biz = new InventoryPeriodBIZ();
            InventoryPeriodDTO dto;

            if (LoadCurrentPeriod)
            {
                dto = biz.LoadCurrentPeriod();
            }
            else
            {
                dto = biz.LoadPeriodByDate(new NZDateTime(dtInventoryMonth, dtInventoryMonth.Value));
            }
            if (dto != null)
            {
                int year  = Convert.ToInt32(dto.YEAR_MONTH.StrongValue.Substring(0, 4));
                int month = Convert.ToInt32(dto.YEAR_MONTH.StrongValue.Substring(4, 2));
                if (LoadDefaultYearMonth)
                {
                    dtInventoryMonth.Value = new DateTime(year, month, 1);
                }
                dtPeriodFrom.Value = dto.PERIOD_BEGIN_DATE.StrongValue;
                dtPeriodTo.Value   = dto.PERIOD_END_DATE.StrongValue;
            }
            else
            {
                dtPeriodFrom.Value = new DateTime(dtInventoryMonth.Value.Value.Year, dtInventoryMonth.Value.Value.Month, 1);
                dtPeriodTo.Value   = new DateTime(dtInventoryMonth.Value.Value.Year, dtInventoryMonth.Value.Value.Month, DateTime.DaysInMonth(dtInventoryMonth.Value.Value.Year, dtInventoryMonth.Value.Value.Month));
            }
        }
Exemple #2
0
        private NZString GetYearMonth(DateTime?dtDate)
        {
            InventoryPeriodBIZ biz = new InventoryPeriodBIZ();
            InventoryPeriodDTO dto = biz.LoadPeriodByDate(new NZDateTime(null, dtDate.Value));

            if (dto == null)
            {
                return(new NZString(null, dtDate.Value.ToString("yyyyMM")));
            }

            return(dto.YEAR_MONTH);
        }
Exemple #3
0
        private bool CheckMandatory()
        {
            try
            {
                IssueEntryValidator val       = new IssueEntryValidator();
                CommonBizValidator  commonVal = new CommonBizValidator();
                #region Mandatory check

                ErrorItem          errorItem;
                NZString           FromLoc = new NZString(cboFromLoc, cboFromLoc.SelectedValue);
                NZString           ToLoc   = new NZString(cboToLoc, cboToLoc.SelectedValue);
                NZString           ItemCD  = new NZString(txtItemCode, txtItemCode.Text);
                NZString           LotNo   = new NZString(txtLotNo, txtLotNo.Text);
                InventoryPeriodBIZ biz     = new InventoryPeriodBIZ();
                InventoryPeriodDTO dto     = biz.LoadPeriodByDate(new NZDateTime(dtIssueDate, dtIssueDate.Value));

                errorItem = val.CheckIssueDate(new NZDateTime(null, dtIssueDate.Value));
                if (null != errorItem)
                {
                    // ถ้าเป็น issue ของเดือนถัดไปจะต้องทำได้
                    errorItem = val.CheckIssueMonth(new NZDateTime(null, dtIssueDate.Value));
                    if (null != errorItem)
                    {
                        ValidateException.ThrowErrorItem(errorItem);
                    }
                }

                errorItem = val.CheckEmptyItemCode(ItemCD);
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = val.CheckEmptyLocFrom(FromLoc);
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = val.CheckEmptyLocTo(ToLoc);
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                errorItem = val.CheckFromToLocation(FromLoc, ToLoc);
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                if (m_Mode == eSaveMode.ADD)
                {
                    //if (txtLotNo.Text == string.Empty)
                    //    ValidateException.ThrowErrorItem(new ErrorItem(txtLotNo,
                    //                                                   TKPMessages.eValidate.VLM0067.ToString(),
                    //                                                   new[] { FromLoc.StrongValue }));
                    errorItem = commonVal.CheckInputLot(ItemCD, FromLoc, LotNo, true);
                    if (null != errorItem)
                    {
                        ValidateException.ThrowErrorItem(errorItem);
                    }
                }
                if (txtIssueQty.Text.Trim() == string.Empty)
                {
                    txtIssueQty.Text = "0";
                }
                if (txtOnHandQty.Text.Trim() == string.Empty)
                {
                    txtOnHandQty.Text = "0";
                }

                errorItem = val.CheckIssueQTY(new NZDecimal(txtIssueQty, Convert.ToDecimal(txtIssueQty.Text)));
                if (null != errorItem)
                {
                    ValidateException.ThrowErrorItem(errorItem);
                }

                #endregion

                return(true);
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
                err.Error.FocusOnControl();
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
            return(false);
        }