Exemple #1
0
        private void cmdVerify_Click(object sender, RoutedEventArgs e)
        {
            Boolean r = SaveToView();

            if (!r)
            {
                return;
            }

            CUtil.EnableForm(false, this);
            CTable t = OnixWebServiceAPI.VerifyVoidedDoc(vw.GetDbObject().CloneAll());

            CUtil.EnableForm(true, this);

            if (t != null)
            {
                MInventoryDoc ivd = new MInventoryDoc(t);
                ivd.InitErrorItem();
                if (ivd.ErrorItems.Count > 0)
                {
                    WinErrorDetails w = new WinErrorDetails(ivd.ErrorItems, "InventoryDoc");
                    w.Title = CLanguage.getValue("approve_error");
                    w.ShowDialog();
                }
                else
                {
                    String msg = CLanguage.getValue("VERIFY_SUCCESS");
                    CMessageBox.Show(msg, "SUCCESS", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }
        private void cmdVerify_Click(object sender, RoutedEventArgs e)
        {
            Boolean r = SaveToView();

            if (!r)
            {
                return;
            }

            CUtil.EnableForm(false, this);
            vw.DocumentType = ((int)dt).ToString();
            CTable t = verifyAccountDocWrapper();

            CUtil.EnableForm(true, this);
            if (t != null)
            {
                MInventoryDoc ivd = new MInventoryDoc(t);
                ivd.InitErrorItem();
                if (ivd.ErrorItems.Count > 0)
                {
                    WinErrorDetails w = new WinErrorDetails(ivd.ErrorItems, "InventoryDoc");
                    w.Title = CLanguage.getValue("approve_error");
                    w.ShowDialog();
                }
                else
                {
                    String msg = CLanguage.getValue("VERIFY_SUCCESS");
                    CMessageBox.Show(msg, "SUCCESS", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }
Exemple #3
0
        private void mnuContextMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem mnu  = (sender as MenuItem);
            string   name = mnu.Name;

            if (name.Equals("mnuEdit"))
            {
                showEditWindow();
            }
            else if (name.Equals("mnuCopy"))
            {
                CUtil.EnableForm(false, ParentControl);
                CTable newobj = OnixWebServiceAPI.SubmitObjectAPI("CopyInventoryDoc", currentObj.GetDbObject());

                if (newobj != null)
                {
                    MInventoryDoc ivd = new MInventoryDoc(newobj);
                    ItemAddedEvent(ivd, e);
                }
                else
                {
                    //Error here
                    CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), "ERROR_USER_ADD", null);
                }

                CUtil.EnableForm(true, ParentControl);
            }
        }
Exemple #4
0
        private Boolean SaveData()
        {
            if (!CHelper.VerifyAccessRight("SALE_VOID_EDIT"))
            {
                return(false);
            }

            //if (!vw.IsModified)
            //{
            //    return (true);
            //}

            Boolean result = SaveToView();

            if (!result)
            {
                return(false);
            }

            CUtil.EnableForm(false, this);
            CTable t = OnixWebServiceAPI.ApproveVoidedDoc(vw.GetDbObject());

            CUtil.EnableForm(true, this);
            if (t != null)
            {
                MInventoryDoc ivd = new MInventoryDoc(t);
                ivd.InitErrorItem();
                if (ivd.ErrorItems.Count > 0)
                {
                    WinErrorDetails w = new WinErrorDetails(ivd.ErrorItems, "InventoryDoc");
                    w.Title = CLanguage.getValue("approve_error");
                    w.ShowDialog();

                    return(false);
                }
                else
                {
                    accDoc.SetDbObject(t);
                    accDoc.NotifyAllPropertiesChanged();

                    return(true);
                }
            }

            CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), "ERROR_USER_EDIT", null);
            CUtil.EnableForm(true, this);

            return(false);
        }
Exemple #5
0
        protected Boolean approveData()
        {
            if (!CHelper.VerifyAccessRight(accessRightName))
            {
                return(false);
            }

            if (!validateData())
            {
                return(false);
            }

            CUtil.EnableForm(false, this);
            CTable newobj = OnixWebServiceAPI.SubmitObjectAPI(approveAPIName, vw.GetDbObject());

            CUtil.EnableForm(true, this);

            if (newobj == null)
            {
                //Error here
                CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), "ERROR_USER_ADD", null);
                return(false);
            }

            MInventoryDoc vcd = new MInventoryDoc(newobj);

            vcd.InitErrorItem();
            if (vcd.ErrorItems.Count > 0)
            {
                WinErrorDetails w = new WinErrorDetails(vcd.ErrorItems, "InventoryDoc");
                w.Title = CLanguage.getValue("approve_error");
                w.ShowDialog();

                return(false);
            }

            if (loadParam.Mode.Equals("A"))
            {
                vw.SetDbObject(newobj);
                loadParam.ParentItemSources.Insert(0, vw);
            }
            else
            {
                loadParam.ActualView.SetDbObject(newobj);
                loadParam.ActualView.NotifyAllPropertiesChanged();
            }

            return(true);
        }
Exemple #6
0
        public WinAddEditBorrowReturnItem(CWinLoadParam param) : base(param)
        {
            accessRightName = "INVENTORY_BORROW_EDIT";
            mvParent        = (MInventoryDoc)loadParam.ActualParentView;

            dt = (InventoryDocumentType)CUtil.StringToInt(param.GenericType);

            InitializeComponent();

            //Need to be after InitializeComponent
            registerValidateControls(lblCode, lkupItem, false);
            registerValidateControls(lblQuantity, txtQuantity, false);
            registerValidateControls(lblUnitPrice, txtUnitPrice, false);
            registerValidateControls(lblLotNo, txtLotSerial1, false);
        }
        private void createInfoEntries()
        {
            AddInfoControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_LABEL, "", "from_location"));
            AddInfoControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_TEXT_BOX, "LocationToName", ""));

            MInventoryTransaction m = (MInventoryTransaction)model;
            MInventoryDoc         d = (MInventoryDoc)GetDefaultData();

            if (d != null)
            {
                m.LocationID      = d.ToLocation;
                m.LocationToName  = d.ToLocationName;
                m.ReturnedAllFlag = "N";
            }
        }
Exemple #8
0
        protected override MBaseModel createObject()
        {
            mv = new MInventoryDoc(new CTable(""));

            mv.DocumentType  = ((int)dt).ToString();
            mv.IsInternalDoc = false;
            mv.AllowNegative = false;
            mv.DocumentDate  = DateTime.Now;
            mv.DocumentDate  = DateTime.Now;
            mv.ReturnDueDate = DateTime.Now;
            mv.CreateDefaultValue();

            mv.AdjustByDeltaFlag = "N";
            if (adjustByDelta)
            {
                mv.AdjustByDeltaFlag = "Y";
            }

            if ((dt == InventoryDocumentType.InvDocImport) || (dt == InventoryDocumentType.InvDocAdjust))
            {
                cboFrom.IsEnabled = false;
            }
            else if (dt == InventoryDocumentType.InvDocExport)
            {
                cboTo.IsEnabled = false;
            }

            if (loadParam.Mode.Equals("A"))
            {
                ObservableCollection <MLocation> locations = CMasterReference.Instance.Locations;
                if (locations.Count > 1)
                {
                    MLocation b = locations[1];
                    if (cboFrom.IsEnabled)
                    {
                        mv.FromLocationObj = b;
                    }

                    if (cboTo.IsEnabled)
                    {
                        mv.ToLocationObj = b;
                    }
                }
            }

            return(mv);
        }
Exemple #9
0
        public override Tuple <CTable, ObservableCollection <MBaseModel> > QueryData()
        {
            (model as MInventoryDoc).DocumentType = ((int)docType).ToString();
            items = OnixWebServiceAPI.GetListAPI("GetInventoryDocList", "INVENTORY_DOC_LIST", model.GetDbObject());
            lastObjectReturned = OnixWebServiceAPI.GetLastObjectReturned();

            itemSources.Clear();
            int idx = 0;

            foreach (CTable o in items)
            {
                MInventoryDoc v = new MInventoryDoc(o);

                v.RowIndex = idx;
                itemSources.Add(v);
                idx++;
            }

            Tuple <CTable, ObservableCollection <MBaseModel> > tuple = new Tuple <CTable, ObservableCollection <MBaseModel> >(lastObjectReturned, itemSources);

            return(tuple);
        }
Exemple #10
0
        protected Boolean verifyData()
        {
            if (!validateData())
            {
                return(false);
            }

            CUtil.EnableForm(false, this);
            CTable newobj = OnixWebServiceAPI.SubmitObjectAPI(verifyAPIName, vw.GetDbObject());

            CUtil.EnableForm(true, this);

            if (newobj == null)
            {
                //Error here
                CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), "ERROR_USER_ADD", null);
                return(false);
            }

            MInventoryDoc vcd = new MInventoryDoc(newobj);

            vcd.InitErrorItem();
            if (vcd.ErrorItems.Count > 0)
            {
                WinErrorDetails w = new WinErrorDetails(vcd.ErrorItems, "InventoryDoc");
                w.Title = CLanguage.getValue("approve_error");
                w.ShowDialog();

                return(false);
            }
            else
            {
                String msg = CLanguage.getValue("VERIFY_SUCCESS");
                CMessageBox.Show(msg, "SUCCESS", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            return(true);
        }
        public UFormInventoryExportDoc(MBaseModel model, int page, int totalPage, MReportConfig cfg, CReportPageParam param)
        {
            if (model == null)
            {
                model = new MInventoryDoc(new Wis.WsClientAPI.CTable(""));
            }

            dataSource = model;
            pageNo     = page;
            pageCount  = totalPage;
            pageParam  = param;
            rptConfig  = cfg;

            init();

            MInventoryDoc ad = (dataSource as MInventoryDoc);

            numberTextAmount = "";
            amountFmt        = "";

            primaryColumns.Clear();

            primaryColumns.Add(new GridLength(10, GridUnitType.Star));
            primaryColumns.Add(new GridLength(20, GridUnitType.Star));
            primaryColumns.Add(new GridLength(40, GridUnitType.Star));
            primaryColumns.Add(new GridLength(15, GridUnitType.Star));
            primaryColumns.Add(new GridLength(15, GridUnitType.Star));

            DataContext = model;
            InitializeComponent();

            //These 2 lines are important to place here after InitializeComponent();
            headerPanel = grdBody;
            tablePanel  = dckBody;

            descriptionColumnIndex = 2;
        }
Exemple #12
0
        protected override Boolean postValidate()
        {
            if (dt == InventoryDocumentType.InvDocXfer)
            {
                MInventoryDoc d = (MInventoryDoc)vw;

                if (d.FromLocation.Equals(d.ToLocation))
                {
                    //Not allow to xfer in the same location
                    CHelper.ShowErorMessage("", "ERROR_XFER_SAME_LOCATION", null);
                    return(false);
                }
            }
            else if ((dt == InventoryDocumentType.InvDocAdjust) && !adjustByDelta)
            {
                Boolean result = validateAdjustItems(mv.AdjustmentItems, tbiAdjustment, true);
                if (!result)
                {
                    return(result);
                }
            }

            return(true);
        }
Exemple #13
0
        protected override void addSubItem()
        {
            MInventoryDoc parent = (MInventoryDoc)loadParam.ActualParentView;

            parent.AddTxItem(mv, dt);
        }
        private Boolean SaveData(String approveFlag)
        {
            if (!CHelper.VerifyAccessRight(getAccessRightEdit()))
            {
                return(false);
            }

            vw.DocumentType = ((int)dt).ToString();
            vw.ConstructWhDefinitionFromDocItem();

            if (approveFlag.Equals("Y"))
            {
                Boolean result = SaveToView();
                if (!result)
                {
                    return(false);
                }

                CUtil.EnableForm(false, this);

                populateBillSimulate(vw);
                CTable t = approveAccountDocWrapper();

                CUtil.EnableForm(true, this);
                if (t != null)
                {
                    //Intend to use MInventoryDoc
                    MInventoryDoc vcd = new MInventoryDoc(t);
                    vcd.InitErrorItem();
                    if (vcd.ErrorItems.Count > 0)
                    {
                        WinErrorDetails w = new WinErrorDetails(vcd.ErrorItems, "InventoryDoc");
                        w.Title = CLanguage.getValue("approve_error");
                        w.ShowDialog();
                    }
                    else
                    {
                        if (Mode.Equals("A"))
                        {
                            vw.SetDbObject(t);
                            vw.DocumentStatus = ((int)CashDocumentStatus.CashDocApproved).ToString();
                            (vw as MAccountDoc).NotifyAllPropertiesChanged();
                            createdID = vw.AccountDocId;
                            if (itemAddedHandler != null)
                            {
                                itemAddedHandler(vw, null);
                            }
                            else
                            {
                                //Will be obsoleted soon
                                parentItemsSource.Insert(0, vw);
                            }
                        }
                        else if (Mode.Equals("E"))
                        {
                            if (!isBillCorrection)
                            {
                                actualView.SetDbObject(t);
                                actualView.DocumentStatus = ((int)CashDocumentStatus.CashDocApproved).ToString();
                                (actualView as MAccountDoc).NotifyAllPropertiesChanged();
                            }
                        }

                        vw.IsModified = false;
                        this.Close();
                    }
                }
            }
            else if (Mode.Equals("A"))
            {
                if (SaveToView())
                {
                    CUtil.EnableForm(false, this);
                    vw.IsPromotionMode = isPromotionMode;
                    CTable newobj = OnixWebServiceAPI.CreateAccountDoc(vw.GetDbObject());
                    CUtil.EnableForm(true, this);
                    if (newobj != null)
                    {
                        vw.SetDbObject(newobj);
                        if (itemAddedHandler != null)
                        {
                            itemAddedHandler(vw, null);
                        }
                        else
                        {
                            //Will be obsoleted soon
                            parentItemsSource.Insert(0, vw);
                        }

                        return(true);
                    }

                    //Error here
                    CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), "ERROR_USER_ADD", null);
                    return(false);
                }
            }
            else if (Mode.Equals("E"))
            {
                if (vw.IsModified)
                {
                    Boolean result = SaveToView();
                    if (result)
                    {
                        CUtil.EnableForm(false, this);
                        CTable t = updateDocumentWrapper();
                        CUtil.EnableForm(true, this);
                        if (t != null)
                        {
                            if (!isBillCorrection)
                            {
                                actualView.SetDbObject(t);
                                (actualView as MAccountDoc).NotifyAllPropertiesChanged();
                            }
                            return(true);
                        }

                        CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), "ERROR_USER_EDIT", null);
                    }

                    return(false);
                }

                return(true);
            }

            return(false);
        }
Exemple #15
0
        private void createAdjustDoc()
        {
            String toLocationCode = "LOCATION01";
            String toLocationID   = "2";

            MInventoryDoc md = new MInventoryDoc(new CTable(""));

            md.DocumentDate   = DateTime.Now;
            md.DocumentType   = "4";
            md.ToLocation     = toLocationID;
            md.ToLocationCode = toLocationCode;
            md.AdjustmentBy   = "1";
            md.IsInternalDoc  = false;

            int internalCnt = 0;
            int docCnt      = 0;

            foreach (CTable o in inventoryItems)
            {
                MInventoryItem mi = new MInventoryItem(o);
                //en.Note = String.Format("META|{0}|{1}|{2}|{3}|{4}|{5}",
                //    en.ItemUOMName,
                //    en.ItemCategoryName,
                //    en.ItemTypeName,
                //    en.Temp2,
                //    en.Temp3,
                //    en.Temp4
                //    );
                //"Temp2", //จำนวนคงเหลือ
                //"Temp3", //ราคา/หน่วย
                //"Temp4", //มูลค่าคงเหลือ

                string source = mi.Note;
                if (source.Equals(""))
                {
                    continue;
                }

                string[] stringSeparators = new string[] { "|" };
                string[] results          = source.Split(stringSeparators, StringSplitOptions.None);

                if (results.Length < 7)
                {
                    continue;
                }

                String balanceQty = results[4];
                String balanceAmt = results[6];

                if (internalCnt >= 30)
                {
                    docCnt++;

                    md.Note = "ตั้งยอดยกมา 000" + docCnt;

                    OnixWebServiceAPI.SubmitObjectAPI("CreateInventoryDoc", md.GetDbObject());

                    md = new MInventoryDoc(new CTable(""));
                    md.IsInternalDoc  = false;
                    md.DocumentDate   = DateTime.Now;
                    md.DocumentType   = "4";
                    md.ToLocation     = toLocationID;
                    md.ToLocationCode = toLocationCode;
                    md.AdjustmentBy   = "1";

                    internalCnt = 0;
                }

                MInventoryAdjustment ai = new MInventoryAdjustment(new CTable(""));
                ai.ExtFlag             = "A";
                ai.ItemID              = mi.ItemID;
                ai.ItemCode            = mi.ItemCode;
                ai.AdjQuantity         = balanceQty;
                ai.AdjAmount           = balanceAmt;
                ai.AdjustmentByDetails = "1";
                md.AddAdjustment(ai);

                importStatusUpdate(internalCnt, inventoryItems.Count);
                internalCnt++;
            }

            if (internalCnt > 0)
            {
                docCnt++;
                md.Note = "ตั้งยอดยกมา 000" + docCnt;
                OnixWebServiceAPI.SubmitObjectAPI("CreateInventoryDoc", md.GetDbObject());
            }

            importStatusUpdate(inventoryItems.Count, inventoryItems.Count);
        }
Exemple #16
0
        private void showEditWindow()
        {
            CWinLoadParam param = new CWinLoadParam();
            MInventoryDoc v     = (MInventoryDoc)currentObj;

            param.Mode              = "E";
            param.GenericType       = ((int)docType).ToString();
            param.ActualView        = currentObj;
            param.ParentItemSources = itemSources;

            String caption = "";
            int    mode    = 1;

            if (docType == InventoryDocumentType.InvDocImport)
            {
                caption = CLanguage.getValue("inventory_import");
                if (!CHelper.VerifyAccessRight("INVENTORY_IMPORT_VIEW"))
                {
                    return;
                }
            }
            else if (docType == InventoryDocumentType.InvDocExport)
            {
                caption = CLanguage.getValue("inventory_export");
                if (!CHelper.VerifyAccessRight("INVENTORY_EXPORT_VIEW"))
                {
                    return;
                }
            }
            else if (docType == InventoryDocumentType.InvDocXfer)
            {
                caption = CLanguage.getValue("inventory_xfer");
                if (!CHelper.VerifyAccessRight("INVENTORY_XFER_VIEW"))
                {
                    return;
                }
            }
            else if (docType == InventoryDocumentType.InvDocAdjust)
            {
                caption = CLanguage.getValue("inventory_adjust");
                if (!CHelper.VerifyAccessRight("INVENTORY_ADJUST_VIEW"))
                {
                    return;
                }
            }
            else if (docType == InventoryDocumentType.InvDocBorrow)
            {
                mode    = 2;
                caption = CLanguage.getValue("inventory_borrow");
                if (!CHelper.VerifyAccessRight("INVENTORY_BORROW_VIEW"))
                {
                    return;
                }
            }
            else if (docType == InventoryDocumentType.InvDocReturn)
            {
                mode    = 2;
                caption = CLanguage.getValue("inventory_return");
                if (!CHelper.VerifyAccessRight("INVENTORY_RETURN_VIEW"))
                {
                    return;
                }
            }

            param.Caption = CLanguage.getValue("edit") + " " + caption;;
            if (mode == 1)
            {
                param.GenericFlag = v.IsAdjustByDelta;
                FactoryWindow.ShowWindow("WinAddEditInventoryDoc", param);
            }
            else if (mode == 2)
            {
                FactoryWindow.ShowWindow("WinAddEditBorrowReturnDoc", param);
            }
        }
        private Boolean SaveData(String approveFlag)
        {
            if (!CHelper.VerifyAccessRight(getAccessRightEdit()))
            {
                return(false);
            }

            vw.DocumentType = ((int)dt).ToString();
            vw.ConstructWhDefinitionFromCrDr();
            vw.CalculateARAmountForDrCr();

            if (approveFlag.Equals("Y"))
            {
                Boolean result = SaveToView();
                if (!result)
                {
                    return(false);
                }

                CUtil.EnableForm(false, this);
                CTable t = OnixWebServiceAPI.ApproveAccountDoc(vw.GetDbObject().Clone());
                CUtil.EnableForm(true, this);
                if (t != null)
                {
                    MInventoryDoc vcd = new MInventoryDoc(t);
                    vcd.InitErrorItem();
                    if (vcd.ErrorItems.Count > 0)
                    {
                        WinErrorDetails w = new WinErrorDetails(vcd.ErrorItems, "InventoryDoc");
                        w.Title = CLanguage.getValue("approve_error");
                        w.ShowDialog();
                    }
                    else
                    {
                        if (Mode.Equals("A"))
                        {
                            vw.SetDbObject(t);
                            vw.DocumentStatus = ((int)CashDocumentStatus.CashDocApproved).ToString();
                            (vw as MAccountDoc).NotifyAllPropertiesChanged();

                            if (itemAddedHandler != null)
                            {
                                itemAddedHandler(vw, null);
                            }
                            else
                            {
                                //Will be obsoleted soon
                                parentItemsSource.Insert(0, vw);
                            }
                        }
                        else if (Mode.Equals("E"))
                        {
                            actualView.SetDbObject(t);
                            actualView.DocumentStatus = ((int)CashDocumentStatus.CashDocApproved).ToString();
                            (actualView as MAccountDoc).NotifyAllPropertiesChanged();
                        }

                        vw.IsModified = false;
                        this.Close();
                    }
                }
            }

            else if (Mode.Equals("A"))
            {
                //Not used
            }
            else if (Mode.Equals("E"))
            {
                if (vw.IsModified)
                {
                    Boolean result = SaveToView();
                    if (result)
                    {
                        CUtil.EnableForm(false, this);
                        CTable t = OnixWebServiceAPI.AdjustApproveAccountDoc(vw.GetDbObject());
                        CUtil.EnableForm(true, this);
                        if (t != null)
                        {
                            actualView.SetDbObject(t);
                            actualView.NotifyAllPropertiesChanged();

                            return(true);
                        }

                        CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), "ERROR_USER_EDIT", null);
                    }

                    return(false);
                }

                return(true);
            }

            return(false);
        }
        public override MBaseModel CreateDefaultData()
        {
            MInventoryDoc ma = new MInventoryDoc(new CTable(""));

            return(ma);
        }