コード例 #1
0
        void m_keyboardSpread_RowRemoving(object sender, EventRowRemoving e)
        {
            MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9002.ToString()), MessageDialogButtons.YesNo);

            if (dr == MessageDialogResult.No)
            {
                e.Cancel = true;
            }
        }
コード例 #2
0
        public override void OnSaveAndClose()
        {
            fpView.StopCellEditing();
            if (m_bRowHasModified)
            { // ถ้า Row กำลังแก้ไขอยู่
                if (!ValidateRowSpread(shtView.ActiveRowIndex, false))
                {
                    return;
                }
            }
            // ต้องเรียกก่อน Save เสมอ  เพื่อ Commit ข้อมูลการแก้ไขล่าสุดบน Grid
            // ใช้ได้เฉพาะกับ Sheet ที่ผูก DataSource
            CtrlUtil.SpreadSheetRowEndEdit(shtView, shtView.ActiveRowIndex);
            RemoveRowUnused(shtView);
            ////if (txtItemCode.SelectedItemData != null)
            ////    numWorkResultQty_KeyPress(numWorkResultQty, new KeyPressEventArgs((char)Keys.Return));

            if (txtNumberOfBox.Int <= 0)
            {
                txtNumberOfBox.Int = 1;
            }

            try
            {
                ValidateBeforeSave();

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9001.ToString()));
                if (dr == MessageDialogResult.Cancel)
                {
                    return;
                }
                if (dr == MessageDialogResult.Yes)
                {
                    SaveData();
                }

                m_dialogResult = DialogResult.OK;
                this.Close();
            }
            catch (ValidateException err)
            {
                for (int i = 0; i < err.ErrorResults.Count; i++)
                {
                    MessageDialog.ShowBusiness(this, err.ErrorResults[i].Message);
                    err.ErrorResults[i].FocusOnControl();
                }
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
                err.Error.FocusOnControl();
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }
コード例 #3
0
        private void btnPrintTag_Click(object sender, EventArgs e)
        {
            try
            {
                ErrorItem err = CheckCanRunProcess();
                if (err != null)
                {
                    MessageDialog.ShowBusiness(this, err.Message);
                    this.Close();
                    return;
                }

                try
                {
                    if (txtPreProcessBy.Text.Trim().Length == 0)
                    {
                        MessageDialog.ShowBusiness(this
                                                   , new EVOFramework.Message(TKPMessages.eValidate.VLM0086.ToString()));

                        return;
                    }

                    ReportBIZ biz = new ReportBIZ();


                    DataSet ds = biz.LoadStockTakingTagSummary();


                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        string strReportFileName = @"Report\STR040_StockTakingTagSummary.rpt";


                        RPT999_PreviewReport preview = new RPT999_PreviewReport(
                            Path.Combine(Application.StartupPath, strReportFileName)
                            );

                        preview.SetDataSource(ds);
                        preview.ReportDoc.SetParameterValue("USER", Common.CurrentUserInfomation.Username.ToString().ToUpper());

                        preview.ShowPreview();
                    }
                    else
                    {
                        MessageDialog.ShowInformation(this, null, Message.LoadMessage(TKPMessages.eInformation.INF0001.ToString()).MessageDescription);
                    }
                }
                catch (Exception ex)
                {
                    MessageDialog.ShowBusiness(this, ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }
コード例 #4
0
        public override void OnSaveAndNew()
        {
            fpView.StopCellEditing();
            if (m_bRowHasModified)
            { // ถ้า Row กำลังแก้ไขอยู่
                if (!ValidateRowSpread(shtView.ActiveRowIndex, false))
                {
                    return;
                }
            }
            // ต้องเรียกก่อน Save เสมอ  เพื่อ Commit ข้อมูลการแก้ไขล่าสุดบน Grid
            // ใช้ได้เฉพาะกับ Sheet ที่ผูก DataSource
            CtrlUtil.SpreadSheetRowEndEdit(shtView, shtView.ActiveRowIndex);
            RemoveRowUnused(shtView);

            if (txtNumberOfBox.Int <= 0)
            {
                txtNumberOfBox.Int = 1;
            }

            try
            {
                ValidateBeforeSave();

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9001.ToString()));
                if (dr == MessageDialogResult.Cancel)
                {
                    return;
                }
                if (dr == MessageDialogResult.Yes)
                {
                    SaveData();
                    SetScreenMode(eScreenMode.ADD);

                    CtrlUtil.FocusControl(txtMasterNo);
                    m_dialogResult = DialogResult.OK;
                }
            }
            catch (ValidateException err)
            {
                for (int i = 0; i < err.ErrorResults.Count; i++)
                {
                    MessageDialog.ShowBusiness(this, err.ErrorResults[i].Message);
                    err.ErrorResults[i].FocusOnControl();
                }
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
                err.Error.FocusOnControl();
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }
コード例 #5
0
        /// <summary>
        /// Validate spread row.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="forceValidate">force to validate.</param>
        /// <returns></returns>
        private bool ValidateRowSpread(int row, bool forceValidate)
        {
            string LotNo = shtView.Cells[row, (int)eColView.LOT_NO].Text;

            if (String.IsNullOrEmpty(LotNo))
            {
                ErrorItem error = new ErrorItem(null, TKPMessages.eValidate.VLM0011.ToString());
                MessageDialog.ShowBusiness(this, error.Message);
                return(false);
            }

            string Qty = shtView.Cells[row, (int)eColView.QTY].Text;

            if (String.IsNullOrEmpty(Qty))
            {
                ErrorItem error = new ErrorItem(null, TKPMessages.eValidate.VLM0175.ToString());
                MessageDialog.ShowBusiness(this, error.Message);
                return(false);
            }

            //check format lotno
            if (!(string.Empty.Equals(shtView.Cells[row, (int)eColView.LOT_NO].Text)))
            {
                try
                {
                    FormatUtil.CheckFormatLotNo(new NZString(null, shtView.Cells[row, (int)eColView.LOT_NO].Text));
                }
                catch (ValidateException ex)
                {
                    MessageDialog.ShowBusiness(this, ex.ErrorResults[0].Message);
                    return(false);
                }
            }

            //Check dupllicate lot
            for (int iRow = 0; iRow < shtView.Rows.Count; iRow++)
            {
                if (iRow == row)
                {
                    continue;
                }

                // Check key duplidate.
                string lot_no = shtView.Cells[iRow, (int)eColView.LOT_NO].Text;

                if (Equals(LotNo, lot_no))
                {
                    MessageDialog.ShowBusiness(this, Message.LoadMessage(TKPMessages.eValidate.VLM0189.ToString()));
                    return(false);
                }
            }

            // ถ้า Validate Row ผ่าน แสดงว่า แถวนั้นไม่จำเป็นต้องเช็คอีกรอบ
            m_bRowHasModified = false;
            return(true);
        }
コード例 #6
0
        private void tsbDelete_Click(object sender, EventArgs e)
        {
            MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9002.ToString()));

            if (dr == MessageDialogResult.Cancel)
            {
                return;
            }
            if (dr == MessageDialogResult.Yes)
            {
                DeleteData();
            }
        }
コード例 #7
0
        /// <summary>
        /// Add button into favorite.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private bool AddButtonFavorite(ScreenFavoriteData data)
        {
            // Check duplicate control on container.
            for (int i = 0; i < flowFavorite.Controls.Count; i++)
            {
                ScreenFavoriteData tagData = (ScreenFavoriteData)flowFavorite.Controls[i].Tag;
                if (tagData.SCREEN_CD == data.SCREEN_CD)
                {
                    MessageDialog.ShowBusiness(this, Message.LoadMessage(Messages.eValidate.VLM9017.ToString()));
                    return(false);
                }
            }

            // Save favorite into Container.
            try
            {
                FavoriteButton button = new FavoriteButton();
                button.Tag         = data;
                button.Size        = m_defaultButtonSize;
                button.BackColor   = flowFavorite.BackColor;
                button.BorderColor = ColorHelper.ShiftBrighness(button.BackColor, -100);

                DatabaseScreen dbScreen = m_databaseScreenCache.Get(data.SCREEN_CD);
                if (dbScreen != null)
                {
                    button.Text = dbScreen.ScreenDescription.NVL(string.Empty);

                    ImageItem imageItem = m_imageCache[dbScreen.ImageCD.StrongValue];
                    if (imageItem == null)
                    {
                        button.Image = Properties.Resources.img_not_found;
                    }
                    else
                    {
                        button.Image = imageItem.ImageBin;
                    }
                }

                button.MouseDown += new MouseEventHandler(btnFavorite_MouseDown);
                button.MouseMove += new MouseEventHandler(btnFavorite_MouseMove);
                button.MouseUp   += new MouseEventHandler(btnFavorite_MouseUp);
                button.Click     += new EventHandler(btnFavorite_Click);
                flowFavorite.Controls.Add(button);
                return(true);
            }
            catch (Exception err)
            {
                MessageDialog.ShowBusiness(this, "Can't add favorite. " + err.Message);
                return(false);
            }
        }
コード例 #8
0
        public override void OnSaveAndClose()
        {
            base.OnSaveAndClose();
            try
            {
                UpdateOnhandQtyText();

                ValidateBeforeSave();

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9001.ToString()));
                if (dr == MessageDialogResult.Cancel || dr == MessageDialogResult.No)
                {
                    return;
                }

                if (dr == MessageDialogResult.Yes)
                {
                    AdjustmentEntryUIDM model = dmcAdjust.SaveData(new AdjustmentEntryUIDM());

                    if (m_screenMode == eScreenMode.ADD)
                    {
                        m_controller.SaveAdd(model);
                    }
                    else
                    {
                        m_controller.SaveEdit(m_editTransactionID, model);
                    }
                }

                MessageDialog.ShowInformation(this, null, new Message(Messages.eInformation.INF9003.ToString()).MessageDescription);

                m_isSelected = true;



                this.Close();
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
            }
            catch (Exception err)
            {
                MessageDialog.ShowBusiness(this, null, err.Message);
            }
        }
コード例 #9
0
        private void tsbCancel_Click(object sender, EventArgs e)
        {
            MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9003.ToString()));

            if (dr == MessageDialogResult.Cancel)
            {
                return;
            }
            if (dr == MessageDialogResult.Yes)
            {
                fpView.Enabled = true;
                loadData();
                tsbEdit.Enabled = true;
            }
        }
コード例 #10
0
        private void DeleteItem(NZString transactionID)
        {
            if (MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9002.ToString()), MessageDialogButtons.YesNo) == MessageDialogResult.No)
            {
                return;
            }

            InventoryBIZ biz = new InventoryBIZ();

            biz.DeleteInventoryTransaction(Common.CurrentDatabase, transactionID);

            //LoadData(dtPeriodBegin.NZValue, dtPeriodEnd.NZValue);
            shtView.RemoveRows(shtView.ActiveRowIndex, 1);

            CtrlUtil.SpreadUpdateColumnSorting(shtView);
        }
コード例 #11
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            try
            {
                ErrorItem err = CheckCanRunProcess();
                if (err != null)
                {
                    MessageDialog.ShowBusiness(this, err.Message);
                    return;
                }

                StockTakingDTO dtoStockTaking = new StockTakingDTO();
                dtoStockTaking.STOCK_TAKING_DATE = Convert.ToDateTime(dtpLastSTKDate.DateValue);
                dtoStockTaking.YEAR_MONTH        = txtYearMonth.Text;
                dtoStockTaking.LOCATION_CODE     = Convert.ToString(cboProcess.SelectedValue);

                StockTakingBIZ bizStockTaking         = new StockTakingBIZ();
                string         strTextEffectInventory = bizStockTaking.GetTextEffectInventory(dtoStockTaking);

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new Message(SystemMaintenance.Messages.eConfirm.CFM9009.ToString(), new object[] { strTextEffectInventory }).MessageDescription, MessageDialogButtons.YesNo);
                if (dr == MessageDialogResult.Yes)
                {
                    if (RunProcess())
                    {
                        MessageDialog.ShowBusiness(this, Message.LoadMessage(SystemMaintenance.Messages.eInformation.INF9003.ToString()));
                    }

                    this.cboProcess.SelectedIndex = -1;
                    LoadCurrentStockTakingData();
                }
            }
            catch (ValidateException ex)
            {
                MessageDialog.ShowBusiness(this, ex.ErrorResults[0].Message);
            }
            catch (BusinessException ex)
            {
                MessageDialog.ShowBusiness(this, ex.Error.Message);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }
コード例 #12
0
        private void btnGetTemplate_Click(object sender, EventArgs e)
        {
            try {
                string strFilePath = SaveDialogUtil.GetBrowseFileDialogForExport();
                if (string.Empty.Equals(strFilePath))
                {
                    return;
                }

                string strReportPath = @"Report\STK060_ImportStockTakingTemplate.xls";
                File.Copy(Path.Combine(Application.StartupPath, strReportPath), strFilePath);

                MessageDialog.ShowInformation(this, null, Message.LoadMessage(Messages.eInformation.INF0006.ToString()).MessageDescription);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message, ex.StackTrace);
            }
        }
コード例 #13
0
        private void tsbCancel_Click(object sender, EventArgs e)
        {
            // Do you want to save?
            if (MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9003.ToString()), MessageDialogButtons.YesNo) == MessageDialogResult.No)
            {
                return;
            }

            m_rootBOMNode.Nodes.Clear();
            m_rootBOMNode = new BOMNode();

            shtView.RowCount   = 0;
            shtView.DataSource = null;

            CtrlUtil.ClearControlData(txtItemCD, txtItemDesc);
            CtrlUtil.FocusControl(txtItemCD);

            UpdateUpDownButton();
        }
コード例 #14
0
        private void fpView_Change(object sender, ChangeEventArgs e)
        {
            if (Convert.ToInt32(shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.Shipment].Value) > Convert.ToInt32(shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.ON_HAND_QTY].Value))
            {
                MessageDialog.ShowBusiness(this,
                                           Message.LoadMessage(TKPMessages.eValidate.VLM0104.ToString()).MessageDescription);
                shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.Shipment].Value  = shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.ON_HAND_QTY].Value;
                shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.EDIT_FLAG].Value = true;
                return;
            }

            if (shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.Shipment].Value != null)
            {
                shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.EDIT_FLAG].Value = true;
            }
            else
            {
                shtView.Cells[shtView.ActiveRowIndex, (int)eColumns.EDIT_FLAG].Value = false;
            }
        }
コード例 #15
0
        private void DeleteData()
        {
            ClassListUIDM datamodel = dmc.SaveData(new ClassListUIDM());

            try
            {
                ClassListController ctlsys = new ClassListController();
                int check = ctlsys.DeleteClassList(datamodel);
                if (check == 0)
                {
                    MessageDialog.ShowInformation(this, null, Message.LoadMessage(TKPMessages.eValidate.VLM0068.ToString()).MessageDescription);
                    return;
                }
                else
                {
                    loadData();
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }
コード例 #16
0
        private void tsbOk_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < shtView.Rows.Count; i++)
            {
                if (Convert.ToInt32(shtView.Cells[i, (int)eColumns.Shipment].Value) >
                    Convert.ToInt32(shtView.Cells[i, (int)eColumns.ON_HAND_QTY].Value))
                {
                    MessageDialog.ShowBusiness(this,
                                               Message.LoadMessage(TKPMessages.eValidate.VLM0104.ToString()).MessageDescription);
                    return;
                }

                /*  else if ((Convert.ToBoolean(shtView.Cells[i, (int)eColumns.EDIT_FLAG].Value) == true)
                 *         (Convert.ToInt32(shtView.Cells[i,(int)eColumns.Shipment].Value == null)))
                 * {
                 *     MessageDialog.ShowBusiness(this,
                 *    Message.LoadMessage(TKPMessages.eValidate.VLM0103.ToString()).MessageDescription);
                 *    return;
                 * }
                 */
            }
            DialogResult = DialogResult.OK;
        }
コード例 #17
0
        private void UpdateData()
        {
            SystemConfigurationUIDM datamodel = dmc.SaveData(new SystemConfigurationUIDM());

            try
            {
                SystemConfigController ctlsys = new SystemConfigController();
                int check = ctlsys.UpdateConfig(datamodel);
                if (check == 0)
                {
                    MessageDialog.ShowInformation(this, null, Message.LoadMessage(TKPMessages.eValidate.VLM0100.ToString()).MessageDescription);
                    return;
                }
                else
                {
                    loadData();
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }
コード例 #18
0
        private void LoadData(NZDateTime from, NZDateTime to, NZInt filterType)
        {
            if (dtPeriodBegin.NZValue.IsNull || dtPeriodEnd.NZValue.IsNull)
            {
                if (dtPeriodBegin.NZValue.IsNull && dtPeriodEnd.NZValue.IsNull)
                {
                    MessageDialog.ShowBusiness(this, Message.LoadMessage(TKPMessages.eValidate.VLM0105.ToString(), new object[] { "Period date begin and Delivery date end" }));
                }
                else if (dtPeriodBegin.NZValue.IsNull)
                {
                    MessageDialog.ShowBusiness(this, Message.LoadMessage(TKPMessages.eValidate.VLM0105.ToString(), new object[] { "Period date begin" }));
                }
                else
                {
                    MessageDialog.ShowBusiness(this, Message.LoadMessage(TKPMessages.eValidate.VLM0105.ToString(), new object[] { "Period date end" }));
                }
                return;
            }

            CustomerOrderBIZ biz = new CustomerOrderBIZ();
            DataTable        dt  = DTOUtility.ConvertListToDataTable <CustomerOrderViewDTO>(biz.LoadCustomerOrderList(from, to, filterType, false));

            shtCustomerOrderList.RowCount   = 0;
            shtCustomerOrderList.DataSource = null;
            m_dtAllData = dt;
            FindDataFromMemory();
            CalculateTotal();
            //List<InventoryTransactionViewDTO> list = m_controller.LoadReceivingList(from, to);
            ////DataTable dt = DTOUtility.ConvertListToDataTable(list);
            //m_dtAllData = DTOUtility.ConvertListToDataTable(list);
            //shtCustomerOrderList.RowCount = 0;
            //shtCustomerOrderList.DataSource = null;
            //FindDataFromMemory();
            //shtView.DataSource = m_dtAllData;

            // CtrlUtil.SpreadUpdateColumnSorting(shtView);
        }
コード例 #19
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (cboFromLoc.SelectedValue == null)
     {
         MessageDialog.ShowBusiness(this,
                                    Message.LoadMessage(TKPMessages.eValidate.VLM0103.ToString()));
         return;
     }
     else
     {
         //ถ้าไม่มี row ให้ add ได้ แต่ถ้ามี row ให้ check ว่า row สุดท้ายไม่ใช่ blank
         if ((shtIssueList.RowCount == 0) || (shtIssueList.RowCount > 0 && ValidateRowSpread(shtIssueList.RowCount - 1, true)))
         {
             string loc = Convert.ToString(cboFromLoc.SelectedValue);
             TRN171_LotMaintenance trn171 = new TRN171_LotMaintenance(loc);
             if (DialogResult.OK == trn171.ShowDialog())
             {
                 ItemNo = trn171.ItemNo.ToString();
                 for (int i = 0; i < trn171.shtData.Rows.Count; i++)
                 {
                     if (Convert.ToBoolean(trn171.shtData.Cells[i, (int)eColumns.EDIT_FLAG].Value) == true)
                     {
                         int j = shtIssueList.RowCount;
                         m_keyboardSpread.OnActionAddNewRow();
                         shtIssueList.Cells[j, (int)eColView.ITEM_CODE].Value = trn171.ItemNo.ToString();
                         shtIssueList.Cells[j, (int)eColView.ITEM_DESC].Value = trn171.ItemName.ToString();
                         shtIssueList.Cells[j, (int)eColView.LOT_NO].Value    = trn171.shtData.Cells[i, (int)eColumns.LOT_NO].Value;
                         // shtIssueList.Cells[j, (int)eColView.REQUEST_QTY].Value = trn171.shtData.Cells[i, (int)eColumns.ON_HAND_QTY].Value;
                         shtIssueList.Cells[j, (int)eColView.ISSUE_QTY].Value  = trn171.shtData.Cells[i, (int)eColumns.Shipment].Value;
                         shtIssueList.Cells[j, (int)eColView.ONHAND_QTY].Value = trn171.shtData.Cells[i, (int)eColumns.ON_HAND_QTY].Value;
                     }
                 }
             }
         }
     }
 }
コード例 #20
0
        private void miDeleteOrder_Click(object sender, EventArgs e)
        {
            if (CheckReturnQTY(eReturnType.ORDER, null, shtDelivery.GetValue(shtDelivery.ActiveRowIndex, (int)eColView.ORDER_DETAIL_NO).ToString(), null))
            {
                MessageDialog.ShowBusiness(this, Message.LoadMessage(TKPMessages.eValidate.VLM0202.ToString()));
                return;
            }
            MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(TKPMessages.eConfirm.CFM0008.ToString()));

            switch (dr)
            {
            case MessageDialogResult.Cancel:
                return;

            case MessageDialogResult.No:
                return;

            case MessageDialogResult.Yes:
                break;
            }
            OnDeleteOrder();
            CalTotatValue();
            LoadData();
        }
コード例 #21
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            try
            {
                // Do you want to save?
                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9001.ToString()));
                if (dr == MessageDialogResult.Cancel)
                {
                    return;
                }

                if (dr == MessageDialogResult.Yes)
                {
                    m_executeScript.ExecuteScript();
                    m_executeScript.Clear();
                    MessageDialog.ShowInformation(this, null, Message.LoadMessage(Messages.eInformation.INF9003.ToString()).MessageDescription);
                    return;
                }
            }
            catch (Exception err)
            {
                MessageDialog.ShowBusiness(this, null, err.Message);
            }
        }
コード例 #22
0
        /// <summary>
        /// Validate spread row.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="forceValidate">force to validate.</param>
        /// <returns></returns>
        private bool ValidateRowSpread(int row, bool forceValidate)
        {
            if (!forceValidate && !m_bRowHasModified)
            {
                return(true);
            }

            if (shtView.RowCount <= 0)
            {
                return(true);
            }

            object src_lot_no      = shtView.Cells[row, (int)eColView.LOT_NO].Value;
            object src_cust_lot_no = shtView.Cells[row, (int)eColView.EXTERNAL_LOT_NO].Value;
            object src_qty         = shtView.Cells[row, (int)eColView.QTY].Value;

            if (src_lot_no == null && src_cust_lot_no == null && src_qty == null)
            {
                return(false);
            }

            if (string.Empty.Equals(shtView.Cells[row, (int)eColView.LOT_NO].Text.Trim()))
            {
                MessageDialog.ShowBusiness(this, Message.LoadMessage(TKPMessages.eValidate.VLM0011.ToString()));
                return(false);
            }

            //check format lotno
            if (!(string.Empty.Equals(shtView.Cells[row, (int)eColView.LOT_NO].Text)))
            {
                try
                {
                    FormatUtil.CheckFormatLotNo(new NZString(null, shtView.Cells[row, (int)eColView.LOT_NO].Text));
                }
                catch (ValidateException ex)
                {
                    MessageDialog.ShowBusiness(this, ex.ErrorResults[0].Message);
                    return(false);
                }
            }

            //Check dupllicate lot
            //for (int iRow = 0; iRow < shtView.Rows.Count; iRow++)
            //{
            //    if (iRow == row)
            //        continue;

            //    // Check key duplidate.
            //    object lot_no = shtView.Cells[iRow, (int)eColView.LOT_NO].Value;

            //    if (Equals(src_lot_no, lot_no))
            //    {
            //        MessageDialog.ShowBusiness(this, Message.LoadMessage(TKPMessages.eValidate.VLM0189.ToString()));
            //        return false;
            //    }
            //}

            //Check Qty > 0
            if (src_qty == null || Convert.ToInt32(src_qty) <= 0)
            {
                MessageDialog.ShowBusiness(this, Message.LoadMessage(TKPMessages.eValidate.VLM0175.ToString()));
                return(false);
            }

            // ถ้า Validate Row ผ่าน แสดงว่า แถวนั้นไม่จำเป็นต้องเช็คอีกรอบ
            m_bRowHasModified = false;
            return(true);
        }
コード例 #23
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.Empty.Equals(txtLastPreProcessBy.Text))
                {
                    MessageDialog.ShowBusiness(this, Message.LoadMessage(TKPMessages.eValidate.VLM0086.ToString()));
                    return;
                }

                MessageDialogResult dialog = MessageDialog.ShowConfirmation(this, Message.LoadMessage(TKPMessages.eConfirm.CFM0005.ToString()));
                if (dialog == MessageDialogResult.Cancel || dialog == MessageDialogResult.No)
                {
                    return;
                }

                string strFilePath = txtFileName.Text.Trim();

                //Check found data in file
                DataTable dt = ImportUtil.ImportExcel(strFilePath, CONST_B_DATA_INCLUDE_HEADER, 0);
                if (dt == null || dt.Rows.Count == 0)
                {
                    ErrorItem error = new ErrorItem(null, TKPMessages.eValidate.VLM0156.ToString());
                    ValidateException.ThrowErrorItem(error);
                }

                if (dt.Columns.Count < ((int)eImportFile.Remark) + 1)
                {
                    ErrorItem error = new ErrorItem(null, TKPMessages.eValidate.VLM0178.ToString());
                    ValidateException.ThrowErrorItem(error);
                }

                List <ImportStockTakingDTO> dtoList = new List <ImportStockTakingDTO>();
                int iLineNo = CONST_B_DATA_INCLUDE_HEADER ? CONST_INT_START_RECORD_NO : 0;
                foreach (DataRow dr in dt.Rows)
                {
                    if (("".Equals(dr[(int)eImportFile.Process]) &&
                         "".Equals(dr[(int)eImportFile.MasterNo]) &&
                         "".Equals(dr[(int)eImportFile.Weight]) &&
                         "".Equals(dr[(int)eImportFile.Qty]) &&
                         "".Equals(dr[(int)eImportFile.TagNo]) &&
                         "".Equals(dr[(int)eImportFile.Remark]))

                        || (DBNull.Value.Equals(dr[(int)eImportFile.Process]) &&
                            DBNull.Value.Equals(dr[(int)eImportFile.MasterNo]) &&
                            DBNull.Value.Equals(dr[(int)eImportFile.Weight]) &&
                            DBNull.Value.Equals(dr[(int)eImportFile.Qty]) &&
                            DBNull.Value.Equals(dr[(int)eImportFile.TagNo]) &&
                            DBNull.Value.Equals(dr[(int)eImportFile.Remark])
                            ))
                    {
                        continue;
                    }


                    iLineNo = iLineNo + 1;



                    ImportStockTakingDTO dto = new ImportStockTakingDTO();
                    dto.CREATE_BY        = Common.CurrentUserInfomation.UserCD;
                    dto.CREATE_MACHINE   = Common.CurrentUserInfomation.Machine;
                    dto.IMPORT_FILE_NAME = new NZString(txtFileName, txtFileName.Text.Trim());
                    dto.LINE_NO          = new NZInt(null, iLineNo);
                    dto.PROCESS_CD       = new NZString(null, dr[(int)eImportFile.Process]);
                    dto.ITEM_CD          = new NZString(null, dr[(int)eImportFile.MasterNo]);
                    dto.WEIGHT           = new NZString(null, dr[(int)eImportFile.Weight]);
                    dto.QTY    = new NZString(null, dr[(int)eImportFile.Qty]);
                    dto.TAG_NO = new NZString(null, dr[(int)eImportFile.TagNo]);
                    dto.REMARK = new NZString(null, dr[(int)eImportFile.Remark]);
                    dtoList.Add(dto);
                }

                bool bSuccess = m_controller.ImportStockTakingTemp(strFilePath, ((int)eImportFile.Remark) + 1, dtoList);
                if (bSuccess)
                {
                    MessageDialog.ShowInformation(this, null, Message.LoadMessage(Messages.eInformation.INF9003.ToString()).MessageDescription);
                    InitialScreen();
                    return;
                }
            }
            catch (ValidateException err)
            {
                for (int i = 0; i < err.ErrorResults.Count; i++)
                {
                    MessageDialog.ShowBusiness(this, err.ErrorResults[i].Message);
                    err.ErrorResults[i].FocusOnControl();
                }
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
                err.Error.FocusOnControl();
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }
コード例 #24
0
        public override void OnSaveAndClose()
        {
            fpView.StopCellEditing();
            if (m_bRowHasModified)
            { // ถ้า Row กำลังแก้ไขอยู่
                if (!ValidateRowSpread(shtView.ActiveRowIndex, false))
                {
                    return;
                }
            }
            // ต้องเรียกก่อน Save เสมอ  เพื่อ Commit ข้อมูลการแก้ไขล่าสุดบน Grid
            // ใช้ได้เฉพาะกับ Sheet ที่ผูก DataSource
            CtrlUtil.SpreadSheetRowEndEdit(shtView, shtView.ActiveRowIndex);

            RemoveRowUnused(shtView);

            try
            {
                ItemValidator itemValidator = new ItemValidator();
                int           row           = shtView.Rows.Count;
                for (int i = 0; i < row; i++)
                {
                    NZString          ItemCD = new NZString(null, shtView.Cells[i, (int)eColView.ITEM_CD].Value);
                    BusinessException err    = itemValidator.CheckItemNotExist(ItemCD);
                    if (err != null)
                    {
                        ValidateException.ThrowErrorItem(err.Error);
                    }
                }

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9001.ToString()));
                if (dr == MessageDialogResult.Cancel)
                {
                    return;
                }

                if (dr == MessageDialogResult.Yes)
                {
                    //== Prepare data.
                    ReceivingEntryUIDM newModel = dmcReceive.SaveData(new ReceivingEntryUIDM());
                    newModel.DATA_VIEW = m_model.DATA_VIEW;


                    //== Save Process
                    m_controller.Save(newModel, m_screenMode);

                    // Post-process.
                    m_dialogResult = DialogResult.OK;

                    MessageDialog.ShowInformation(this, null, Message.LoadMessage(Messages.eInformation.INF9003.ToString()).MessageDescription);
                }

                //== Exit form.
                this.Close();
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
                err.Error.FocusOnControl();
            }
            catch (Exception err)
            {
                // ถ้าเป็น error ที่มาจากการหา FIFO Process
                if (err.Message.IndexOf('|') != -1)
                {
                    string[] msgs = err.Message.Split('|');
                    MessageDialog.ShowBusiness(this, Message.LoadMessage(msgs[0], new[] { msgs[1] }));
                }
                else
                {
                    MessageDialog.ShowBusiness(this, null, err.Message);
                }
                Console.WriteLine(err.StackTrace);
            }
        }
コード例 #25
0
        public override void OnSaveAndClose()
        {
            fpView.StopCellEditing();
            if (m_bRowHasModified)
            { // ถ้า Row กำลังแก้ไขอยู่
                if (!ValidateRowSpread(shtView.ActiveRowIndex, false))
                {
                    return;
                }
            }
            // ต้องเรียกก่อน Save เสมอ  เพื่อ Commit ข้อมูลการแก้ไขล่าสุดบน Grid
            // ใช้ได้เฉพาะกับ Sheet ที่ผูก DataSource
            CtrlUtil.SpreadSheetRowEndEdit(shtView, shtView.ActiveRowIndex);
            RemoveRowUnused(shtView);

            try
            {
                UnPackingEntryUIDM model = dmc.SaveData(new UnPackingEntryUIDM());
                model.DATA_VIEW = (DataTable)shtView.DataSource;

                //UpdateRecord(model.DATA_VIEW);

                ValidateBeforeSave(model);

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9001.ToString()));

                if (dr == MessageDialogResult.Yes)
                {
                    for (int i = 0; i < shtView.RowCount; i++)
                    {
                        Boolean Flag = Convert.ToBoolean(shtView.Cells[i, (int)eColView.CHECKBOX].Value);
                        if (Flag == false)
                        {
                            model.DATA_VIEW.Rows.RemoveAt(i);
                            i = i - 1;
                        }
                    }

                    model.DATA_VIEW.AcceptChanges();
                    if (m_screenMode == eScreenMode.ADD)
                    {
                        m_controller.SaveNewUnPacking(model);
                    }
                    //else
                    //    m_controller.SaveUpdatePacking(model);

                    MessageDialog.ShowInformation(this, null, Message.LoadMessage(Messages.eInformation.INF9003.ToString()).MessageDescription);

                    ClearAllExceptDefaultValue();

                    SetScreenMode(eScreenMode.ADD);
                    m_dialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
                err.Error.FocusOnControl();
            }
            catch (Exception err)
            {
                MessageDialog.ShowBusiness(this, null, err.Message);
            }
        }
コード例 #26
0
        public override void OnSaveAndNew()
        {
            base.OnSaveAndNew();

            try
            {
                UpdateOnhandQtyText();


                ValidateBeforeSave();

                MessageDialogResult dr = MessageDialog.ShowConfirmation(this, Message.LoadMessage(Messages.eConfirm.CFM9001.ToString()));
                if (dr == MessageDialogResult.Cancel || dr == MessageDialogResult.No)
                {
                    return;
                }

                if (dr == MessageDialogResult.Yes)
                {
                    AdjustmentEntryUIDM model = dmcAdjust.SaveData(new AdjustmentEntryUIDM());

                    if (m_screenMode == eScreenMode.ADD)
                    {
                        m_controller.SaveAdd(model);
                        ClearAllExceptDefault();
                    }
                    else
                    {
                        m_controller.SaveEdit(m_editTransactionID, model);
                        ClearAll();
                    }


                    MessageDialog.ShowInformation(this, null, new Message(Messages.eInformation.INF9003.ToString()).MessageDescription);
                }

                m_editTransactionID = null;
                SetScreenMode(eScreenMode.ADD);

                m_isSelected = true;



                CtrlUtil.FocusControl(dtAdjustDate);
            }
            catch (ValidateException err)
            {
                MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message);
                err.ErrorResults[0].FocusOnControl();
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message);
                err.Error.FocusOnControl();
            }
            catch (Exception err)
            {
                MessageDialog.ShowBusiness(this, null, err.Message);
            }
            finally
            {
                if (Common.CurrentDatabase.DBConnectionState == ConnectionState.Open)
                {
                    Common.CurrentDatabase.Close();
                }
            }
        }
コード例 #27
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            try
            {
                ErrorItem err = CheckCanRunProcess();
                if (err != null)
                {
                    MessageDialog.ShowBusiness(this, err.Message);
                    this.Close();
                    return;
                }

                try
                {
                    if (txtPreProcessBy.Text.Trim().Length == 0)
                    {
                        MessageDialog.ShowBusiness(this
                                                   , new EVOFramework.Message(TKPMessages.eValidate.VLM0086.ToString()));

                        return;
                    }

                    StockTakingDTO dto = new StockTakingDTO();
                    dto.STOCK_TAKING_DATE = Convert.ToDateTime(dtStockTakingDate.DateValue);
                    dto.LOCATION_CODE     = cboProcess.SelectedValue == null ? string.Empty : cboProcess.SelectedValue.ToString();//txtLocation.Text;
                    dto.PART_NO           = txtMasterNo.Text;
                    dto.PART_TYPE         = Convert.ToString(cboItemType.SelectedValue);
                    dto.PART_SUB_TYPE     = Convert.ToString(cboItemClassMinor04.SelectedValue);

                    if (chkIncomplete.Checked)
                    {
                        dto.SEARCH_INCOMPLETE = 1;
                    }
                    else
                    {
                        dto.SEARCH_INCOMPLETE = 0;
                    }

                    if (chkDiff.Checked)
                    {
                        dto.SEARCH_DIFF = 1;
                    }
                    else
                    {
                        dto.SEARCH_DIFF = 0;
                    }

                    if (chkNoMaster.Checked)
                    {
                        dto.NO_MASTER = 1;
                    }
                    else
                    {
                        dto.NO_MASTER = 0;
                    }

                    DataSet ds = GetReportTable(dto);
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        string strReportFileName = @"Report\STR010_StockCheckingList.rpt";

                        if (rdoReportCheckingList.Checked)
                        {
                            strReportFileName = @"Report\STR010_StockCheckingList.rpt";
                        }
                        else if (rdoReportCountingResult.Checked)
                        {
                            strReportFileName = @"Report\STR020_StockCountingResult.rpt";
                        }
                        else
                        {
                            strReportFileName = @"Report\STR010_StockCheckingList.rpt";
                        }



                        RPT999_PreviewReport preview = new RPT999_PreviewReport(
                            Path.Combine(Application.StartupPath, strReportFileName)
                            );

                        preview.SetDataSource(ds);
                        preview.ReportDoc.SetParameterValue("StockTakingDate", dto.STOCK_TAKING_DATE);
                        preview.ReportDoc.SetParameterValue("IncompleteData", dto.SEARCH_INCOMPLETE);
                        preview.ReportDoc.SetParameterValue("DiffMoreThanZero", dto.SEARCH_DIFF);

                        preview.ShowPreview();
                    }
                    else
                    {
                        MessageDialog.ShowInformation(this, null, Message.LoadMessage(TKPMessages.eInformation.INF0001.ToString()).MessageDescription);
                    }
                }
                catch (Exception ex)
                {
                    MessageDialog.ShowBusiness(this, ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }