Example #1
0
        public UFormNoResidentWithholdingTax(MBaseModel model, int page, int issue, int totalPage, MReportConfig cfg, CReportPageParam param)
        {
            if (model == null)
            {
                model = new MAccountDoc(new Wis.WsClientAPI.CTable(""));
            }

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

            init();

            MAccountDoc ad = (dataSource as MAccountDoc);

            numberTextAmount = ad.CashReceiptAmtFmt;

            primaryColumns.Clear();

            primaryColumns.Add(new GridLength(70, GridUnitType.Star));
            primaryColumns.Add(new GridLength(14, GridUnitType.Star));
            primaryColumns.Add(new GridLength(13, GridUnitType.Star));
            primaryColumns.Add(new GridLength(13, GridUnitType.Star));

            DataContext = model;
            InitializeComponent();
        }
Example #2
0
        private void CmdCheque_Click(object sender, RoutedEventArgs e)
        {
            MVTaxDocument vm = (MVTaxDocument)vw;
            MAccountDoc   ad = CTaxDocumentUtil.TaxDocToAccountDoc(vm, this);

            if (ad == null)
            {
                return;
            }

            if (vm.ChequeID.Equals(""))
            {
                ad.ArApAmt = vm.WhAmount;

                ObservableCollection <MBaseModel> arr = new ObservableCollection <MBaseModel>();
                CCriteriaCheque.ShowAddChequeWindow("2", arr, ad);

                if (arr.Count > 0)
                {
                    MCheque cq = (MCheque)arr[0];
                    vm.ChequeID   = cq.ChequeID;
                    vm.ChequeNo   = cq.ChequeNo;
                    vm.IsModified = true;
                }
            }
            else
            {
                CCriteriaCheque.ShowEditWindow("2", null, ad);
            }
        }
Example #3
0
        public override Tuple <CTable, ObservableCollection <MBaseModel> > QueryData()
        {
            MAccountDoc mp = model as MAccountDoc;

            mp.Category = eType;

            CTable tb = model.GetDbObject();

            String tmpSet = "(1, 2)"; //Only pending and approved, no cancled status

            tb.SetFieldValue("DOCUMENT_STATUS_SET", tmpSet);

            items = OnixWebServiceAPI.GetBillSummaryAbleDocList(tb);

            lastObjectReturned = OnixWebServiceAPI.GetLastObjectReturned();

            itemSources.Clear();
            int idx = 0;

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

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

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

            return(tuple);
        }
Example #4
0
        private ObservableCollection <CDocReceipt> filterItems()
        {
            ObservableCollection <CDocReceipt> temp = new ObservableCollection <CDocReceipt>();
            MAccountDoc md = (MAccountDoc)dataSource;

            int i = 0;

            foreach (MAccountDocReceipt m in pageParam.Items)
            {
                CDocReceipt d = new CDocReceipt(m, Lang);
                d.ItemNo  = (pageParam.StartIndex + i).ToString();
                d.docType = md.DocumentType;
                temp.Add(d);

                i++;
            }

            //int left = itemPerPage - temp.Count;

            for (i = 1; i <= pageParam.PatchRow; i++)
            {
                temp.Add(new CDocReceipt(null, Lang));
            }

            return(temp);
        }
        public WinAddEditDrCrNoteApproved(String md, AccountDocumentType docType, ObservableCollection <MBaseModel> pItems, MAccountDoc actView)
        {
            dt = docType;

            actualView        = actView;
            parentItemsSource = pItems;
            Mode = md;

            vw         = new MAccountDoc(new CTable(""));
            vw.VATType = CGlobalVariable.GetGlobalVariableValue("DEFAULT_VAT_TYPE_SALE");

            if (md.Equals("A") && (actView != null))
            {
                //use actView as default value
                vw.BranchId   = actView.BranchId;
                vw.BranchCode = actView.BranchCode;
                vw.BranchName = actView.BranchName;

                vw.EntityId   = actView.EntityId;
                vw.EntityCode = actView.EntityCode;
                vw.EntityName = actView.EntityName;
            }

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

            InitializeComponent();
        }
        private void cmdSaleOrderUnlink_Click(object sender, RoutedEventArgs e)
        {
            CTable m = new CTable("");

            m.SetFieldValue("ACCOUNT_DOC_ID", vw.RefSaleOrderID);

            CUtil.EnableForm(false, this);
            CTable t = OnixWebServiceAPI.GetAccountDocInfo(m);

            CUtil.EnableForm(true, this);

            if (t == null)
            {
                return;
            }

            MAccountDoc vm = new MAccountDoc(t);
            Boolean     ok = CHelper.AskConfirmMessage(vm.DocumentNo, "ERROR_SALE_ORDER_UNLINK");

            if (!ok)
            {
                return;
            }

            OnixWebServiceAPI.UnlinkSaleOrderFromInvoice(vw.GetDbObject());
            vw.RefSaleOrderID = "";
        }
Example #7
0
        private MAccountDoc constructInvoiceFromSaleOrder(MAccountDoc saleOrder)
        {
            CTable so = OnixWebServiceAPI.GetAccountDocInfo(saleOrder.GetDbObject());

            MAccountDoc sod = new MAccountDoc(so);

            sod.InitAccountDocItem();
            sod.InitEntityAddresses();

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

            md.DocumentType = ((int)docType).ToString();
            md.DocumentDate = sod.DocumentDate;
            md.DocumentDesc = sod.DocumentDesc;
            md.DueDate      = sod.DocumentDate;

            md.ProjectID        = sod.ProjectID;
            md.ProjectCode      = sod.ProjectCode;
            md.ProjectName      = sod.ProjectName;
            md.ProjectGroupName = sod.ProjectGroupName;

            md.EntityId        = sod.EntityId;
            md.EntityCode      = sod.EntityCode;
            md.EntityName      = sod.EntityName;
            md.EntityAddressID = sod.EntityAddressID;

            md.EmployeeID   = sod.EmployeeID;
            md.EmployeeCode = sod.EmployeeCode;
            md.EmployeeName = sod.EmployeeName;

            CTable  cust = OnixWebServiceAPI.GetEntityInfo(sod.EntityObj.GetDbObject());
            MEntity en   = new MEntity(cust);

            en.InitEntityAddress();
            md.ReloadEntityAddresses(en.AddressItems);

            md.BranchId       = sod.BranchId;
            md.VATType        = sod.VATType;
            md.VAT_PCT        = sod.VAT_PCT;
            md.RefSaleOrderNo = sod.DocumentNo;
            md.RefSaleOrderID = sod.AccountDocId;
            md.RefPoNo        = sod.RefPoNo;
            md.RefQuotationNo = sod.RefQuotationNo;

            foreach (MAccountDocItem ad in sod.AccountItem)
            {
                MAccountDocItem adi = new MAccountDocItem(ad.GetDbObject());
                adi.ProjectID   = sod.ProjectID;
                adi.ProjectCode = sod.ProjectCode;
                adi.ProjectName = sod.ProjectName;

                adi.ExtFlag = "A";
                md.AddAccountDocItem(adi);
            }

            md.CalculateExtraFields();
            md.IsModified = true;

            return(md);
        }
Example #8
0
        public override Tuple <CTable, ObservableCollection <MBaseModel> > QueryData()
        {
            MAccountDoc mp = model as MAccountDoc;

            mp.Category = eType;

            CTable tb = model.GetDbObject();

            items = OnixWebServiceAPI.GetReceivableDocList(tb);

            lastObjectReturned = OnixWebServiceAPI.GetLastObjectReturned();

            itemSources.Clear();
            int idx = 0;

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

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

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

            return(tuple);
        }
        private void processPromotion(MAccountDoc doc)
        {
            MBillSimulate billSim = doc.BillSimulate;

            priceHash.Clear();

            CPriceProcessor.SetGetCompanyPackageAllCallback(OnixWebServiceAPI.GetCompanyPackageAll);

            CUtil.EnableForm(false, this);
            CPriceProcessor.LoadStandardPackages(companyPackage);
            CUtil.EnableForm(true, this);

            CBasketSet bks = CPriceProcessor.CreateInitialBasketSet(billSim.SelectedItems);

            CUtil.EnableForm(false, this);
            Boolean tmp = billSim.IsModified;

            CBasketSet output = CPriceProcessor.PromotionProcessing(companyPackage, bks, billSim);

            CPriceProcessor.CreateDisplayProcessingTreeView(billSim);
            CPriceProcessor.CreateDisplayView(output, billSim, updateDisplayItem);

            doc.PromotionAmount        = billSim.TotalAmount;
            doc.PromotionFinalDiscount = billSim.DiscountAmount;
            doc.PromotionTotalAmt      = billSim.NetAmount;
            doc.FreeItemCount          = billSim.FreeItemCount.ToString();
            doc.VoucherItemCount       = billSim.VoucherItemCount.ToString();
            doc.PostFreeItemCount      = billSim.PostFreeItemCount.ToString();
            updateDocumentItemPrice(doc);
            doc.NotifyPromotionCalulation();

            doc.FinalDiscount = billSim.DiscountAmount;

            CUtil.EnableForm(true, this);
        }
Example #10
0
        private MAccountDoc createInvoiceFromSaleOrder()
        {
            MAccountDoc md = null;

            CCriteriaAccountDocSale cr = new CCriteriaAccountDocSale();

            cr.SetActionEnable(false);
            cr.SetDefaultData(new MAccountDoc(new CTable("")));
            cr.SetDocumentType(AccountDocumentType.AcctDocSaleOrder);
            cr.Init("");
            cr.PopulateExtraFields();

            WinLookupSearch2 w = new WinLookupSearch2(cr, CLanguage.getValue("sale_order"));

            w.ShowDialog();

            if (w.IsOK)
            {
                CUtil.EnableForm(false, ParentControl);
                md = constructInvoiceFromSaleOrder((MAccountDoc)w.ReturnedObj);
                CUtil.EnableForm(true, ParentControl);
            }

            return(md);
        }
Example #11
0
        public void PopulateExtraFields()
        {
            MAccountDoc m = (MAccountDoc)model;

            m.IsSaleOrderInUsedByInvoice = false;
            m.DocStatusSet = "(1, 2)";
        }
        public WinAddEditDrCrNote(String md, AccountDocumentType docType, ObservableCollection <MBaseModel> pItems, MAccountDoc actView)
        {
            dt = docType;

            actualView        = actView;
            parentItemsSource = pItems;
            Mode = md;

            vw         = new MAccountDoc(new CTable(""));
            vw.VATType = CGlobalVariable.GetGlobalVariableValue("DEFAULT_VAT_TYPE_SALE");

            //บางครั้งการรับเงินจากลูกค้าล่วงหน้า จะให้ตรงนี้เป็น false แต่ว่าต้องไปรับเข้าเงินสดเองเพื่อให้บัญชี balance
            //รายการตรงนี้ จะไม่ถูกดึงไปคิด ตอนทำภาษีหัก ณ ที่จ่าย หรือ vat เพราะว่า ไม่ได้เป็นส่วนของรายรับ/จ่าย
            vw.ForExpenseRevenue = true;

            if (md.Equals("A") && (actView != null))
            {
                //use actView as default value
                vw.BranchId   = actView.BranchId;
                vw.BranchCode = actView.BranchCode;
                vw.BranchName = actView.BranchName;

                vw.EntityId   = actView.EntityId;
                vw.EntityCode = actView.EntityCode;
                vw.EntityName = actView.EntityName;
            }

            DataContext       = vw;
            vw.IsVatClaimable = true;
            vw.DocumentType   = ((int)dt).ToString();

            InitializeComponent();
        }
Example #13
0
        protected override void initPageCreateFlow()
        {
            IsPageRangeSupport = true;

            MAccountDoc ad = (MAccountDoc)dataSource;

            ad.InitAccountPoItems();
        }
Example #14
0
        public static Boolean ShowDiscountWindow(MAccountDoc doc)
        {
            WinAddEditDiscount w = new WinAddEditDiscount("", doc);

            w.ShowDialog();

            return(w.isOK);
        }
Example #15
0
        protected void init()
        {
            if (dataSource is MAccountDoc)
            {
                MAccountDoc ad = (dataSource as MAccountDoc);

                branchNameThai   = ad.BranchName;
                branchNameEng    = ad.BranchNameEng;
                numberTextAmount = ad.CashReceiptAmtFmt;
            }
        }
Example #16
0
        public WinAddEditVoidedDoc(MAccountDoc doc)
        {
            this.Title = CLanguage.getValue("void_document");

            accDoc          = doc;
            vw.DocumentDate = doc.DocumentDate;
            vw.DocumentNo   = doc.DocumentNo;
            vw.AccountDocID = doc.AccountDocId;

            DataContext = vw;
            InitializeComponent();
        }
Example #17
0
        public WinAddEditDiscount(String rcptAmt, MAccountDoc acctDoc)
        {
            orgDoc = acctDoc;

            doc = new MAccountDoc(acctDoc.GetDbObject().CloneAll());
            doc.InitAccountDocDiscount();
            doc.IsModified = false;

            DataContext = doc;

            InitializeComponent();
        }
Example #18
0
        private MAccountDoc constructSaleOrderFromQuotation(MAuxilaryDoc quotation)
        {
            CTable qt = OnixWebServiceAPI.GetAuxilaryDocInfo(quotation.GetDbObject());

            MAuxilaryDoc qd = new MAuxilaryDoc(qt);

            qd.InitAuxilaryDocItem();
            qd.InitEntityAddresses();

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

            md.DocumentType = ((int)AccountDocumentType.AcctDocSaleOrder).ToString();
            md.DocumentDate = qd.DocumentDate;
            md.DocumentDesc = qd.DocumentDesc;
            md.DueDate      = qd.DocumentDate;

            md.ProjectID        = qd.ProjectID;
            md.ProjectCode      = qd.ProjectCode;
            md.ProjectName      = qd.ProjectName;
            md.ProjectGroupName = qd.ProjectGroupName;

            md.EntityId        = qd.EntityId;
            md.EntityCode      = qd.EntityCode;
            md.EntityName      = qd.EntityName;
            md.EntityAddressID = qd.EntityAddressID;

            md.EmployeeID   = qd.EmployeeID;
            md.EmployeeCode = qd.EmployeeCode;
            md.EmployeeName = qd.EmployeeName;

            CTable  cust = OnixWebServiceAPI.GetEntityInfo(qd.EntityObj.GetDbObject());
            MEntity en   = new MEntity(cust);

            en.InitEntityAddress();
            md.ReloadEntityAddresses(en.AddressItems);

            md.BranchId       = qd.BranchId;
            md.VATType        = qd.VatType;
            md.RefQuotationNo = qd.DocumentNo;
            md.RefQuotationID = qd.AuxilaryDocID;

            foreach (MAuxilaryDocItem ad in qd.AuxilaryDocItems)
            {
                MAccountDocItem adi = new MAccountDocItem(ad.GetDbObject());
                adi.ExtFlag = "A";
                md.AddAccountDocItem(adi);
            }

            md.CalculateExtraFields();
            md.IsModified = true;

            return(md);
        }
        public WinAddEditAccountPurchaseDocApproved(String md, AccountDocumentType docType, ObservableCollection <MBaseModel> pItems, MAccountDoc actView)
        {
            dt = docType;

            actualView        = actView;
            parentItemsSource = pItems;
            Mode = md;

            vw = new MAccountDoc(new CTable(""));
            vw.DocumentType = ((int)dt).ToString();
            DataContext     = vw;

            InitializeComponent();
        }
        public WinAddEditPayment(String rcptAmt, MAccountDoc acctDoc, Boolean arFlag)
        {
            orgDoc = acctDoc;
            isAr   = arFlag;

            doc = new MAccountDoc(acctDoc.GetDbObject().CloneAll());
            doc.InitAccountDocPayment();
            doc.IsModified = false;

            populateCashType(doc);

            DataContext = doc;

            amt = rcptAmt;
            InitializeComponent();
        }
Example #21
0
        public override Tuple <CTable, ObservableCollection <MBaseModel> > QueryData()
        {
            MAccountDoc ad          = (model as MAccountDoc);
            String      tempRefPoNo = ad.RefPoNo;
            String      tempIdxRef  = ad.IndexDocInclude;

            ad.DocumentType = ((int)docType).ToString();
            if (!ad.RefPoNo.Equals(""))
            {
                ad.RefPoNo = "%" + ad.RefPoNo;
            }

            if (!ad.IndexDocInclude.Equals(""))
            {
                ad.IndexDocInclude = "%" + ad.IndexDocInclude;
            }

            CTable t = model.GetDbObject();

            if ((docType == AccountDocumentType.AcctDocCrNotePurchase) || (docType == AccountDocumentType.AcctDocDrNotePurchase))
            {
                t.SetFieldValue("BY_VOID_FLAG", "N");
            }

            items = OnixWebServiceAPI.GetAccountDocList(t);
            lastObjectReturned = OnixWebServiceAPI.GetLastObjectReturned();

            ad.RefPoNo         = tempRefPoNo;
            ad.IndexDocInclude = tempIdxRef;

            itemSources.Clear();
            int idx = 0;

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

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

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

            return(tuple);
        }
Example #22
0
        private void mnuContextMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem mnu  = (sender as MenuItem);
            string   name = mnu.Name;

            if (name.Equals("mnuEdit"))
            {
                ShowEditWindowEx(docType, (MAccountDoc)currentObj, printPreview);
            }
            else if (name.Equals("mnuCopy") || name.Equals("mnuCopyHead"))
            {
                CTable t = currentObj.GetDbObject();
                CUtil.EnableForm(false, ParentControl);

                t.SetFieldValue("IS_ONLY_HEAD", "N");
                if (name.Equals("mnuCopyHead"))
                {
                    t.SetFieldValue("IS_ONLY_HEAD", "Y");
                }

                CTable newobj = OnixWebServiceAPI.CopyAccountDoc(t);

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

                CUtil.EnableForm(true, ParentControl);
            }
            else if (name.Equals("mnuPrint"))
            {
                CUtil.EnableForm(false, ParentControl);

                WinFormPrinting wp = new WinFormPrinting(docTypeToReportGroup(docType), getAccountDocObject((currentObj as MAccountDoc).AccountDocId));
                wp.ShowDialog();

                CUtil.EnableForm(true, ParentControl);
            }
        }
        private void populateBillSimulate(MAccountDoc doc)
        {
            MBillSimulate bs = doc.BillSimulate;

            bs.ClearSelectedItem();

            bs.DocumentDate   = doc.DocumentDate;
            bs.SimulateTime   = doc.DocumentDate;
            bs.CustomerObj    = doc.CustomerObj;
            bs.CustomerID     = doc.EntityId;
            bs.BranchId       = doc.BranchId;
            bs.DocumentType   = doc.DocumentType;
            bs.DocumentStatus = doc.DocumentStatus;

            foreach (MAccountDocItem di in doc.AccountItem)
            {
                if (di.ExtFlag.Equals("D"))
                {
                    continue;
                }

                MSelectedItem si = new MSelectedItem(new CTable(""));

                si.TrayFlag = "N";
                if (di.IsTrayFlag == true)
                {
                    si.TrayFlag = "Y";
                }

                si.SelectionType            = di.SelectType;
                si.ServiceID                = di.ServiceID;
                si.ItemID                   = di.ItemId;
                si.ServiceCode              = di.ServiceCode;
                si.ServiceName              = di.ServiceName;
                si.ItemCode                 = di.ItemCode;
                si.ItemNameThai             = di.ItemNameThai;
                si.ItemQuantity             = di.Quantity;
                si.ItemCategory             = di.ItemCategory;
                si.ServicePricingDefinition = di.ServicePricingDefinition;
                si.PricingDefination        = di.PricingDefinition;
                si.EnabledFlag              = "Y";

                bs.AddSelectedItem(si);
            }
        }
        public WinAddEditAccountSaleDoc(String md, AccountDocumentType docType, ObservableCollection <MBaseModel> pItems, MLogImportIssue actView)
        {
            dt = docType;

            isBillCorrection = true;
            logImportIssue   = actView;
            Mode             = md;

            CTable o = new CTable("");

            o.SetFieldValue("LOG_IMPORT_ISSUE_ID", logImportIssue.LogImportIssueID);

            vw = new MAccountDoc(o);
            vw.DocumentType = ((int)dt).ToString();
            DataContext     = vw;

            InitializeComponent();
        }
        private void cmdOK_Click(object sender, RoutedEventArgs e)
        {
            Boolean r = SaveData("N");

            if (r)
            {
                actualView = vw;
                Mode       = "E";

                LoadData();

                vw.IsModified = false;
                DialogOK      = true;
                CUtil.EnableForm(true, this);

                this.Close();
            }
        }
        public UFormBillSummary(MBaseModel model, int page, int totalPage, MReportConfig cfg, CReportPageParam param)
        {
            if (model == null)
            {
                model = new MAccountDoc(new Wis.WsClientAPI.CTable(""));
            }

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

            init();

            ad = (dataSource as MAccountDoc);
            numberTextAmount = ad.ArApAmt;
            amountFmt        = ad.ArApAmtFmt;

            if (pageNo != pageCount)
            {
                //Only last page will show the number
                numberTextAmount = "";
            }

            primaryColumns.Clear();

            primaryColumns.Add(new GridLength(13, GridUnitType.Star));
            primaryColumns.Add(new GridLength(26, GridUnitType.Star));
            primaryColumns.Add(new GridLength(18, GridUnitType.Star));
            primaryColumns.Add(new GridLength(18, GridUnitType.Star));
            primaryColumns.Add(new GridLength(33, GridUnitType.Star));
            primaryColumns.Add(new GridLength(20, GridUnitType.Star));

            DataContext = model;
            InitializeComponent();

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

            descriptionColumnIndex = 4;
        }
        private void cmdSave_Click(object sender, RoutedEventArgs e)
        {
            if (!vw.IsModified)
            {
                return;
            }

            Boolean r = SaveData("N");

            if (r)
            {
                actualView = vw;
                Mode       = "E";

                LoadData();

                vw.IsModified = false;
            }
        }
Example #28
0
        private void createInfoEntries()
        {
            AddInfoControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_LABEL, "", getKeyMap("code")));
            AddInfoControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_TEXT_BOX, "EntityCode", ""));

            AddInfoControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_LABEL, "", getKeyMap("name")));
            AddInfoControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_TEXT_BOX, "EntityName", ""));

            MAccountDoc m = (MAccountDoc)model;
            MAccountDoc d = (MAccountDoc)GetDefaultData();

            if (d != null)
            {
                m.EntityCode    = d.EntityCode;
                m.EntityName    = d.EntityName;
                m.EntityId      = d.EntityId;
                m.ExcludeDocSet = d.ExcludeDocSet;
            }
        }
        private void ShowEditWindow()
        {
            MAccountDoc ad = new MAccountDoc(new CTable(""));

            ad.DocumentType = currentViewObj.DocumentType;
            ad.AccountDocId = currentViewObj.DocumentID;

            AccountDocumentType dt      = (AccountDocumentType)CUtil.StringToInt(ad.DocumentType);
            AccountDocumentType docType = (AccountDocumentType)CUtil.StringToInt(vw.DocumentType);

            if (docType == AccountDocumentType.AcctDocApReceipt)
            {
                CCriteriaAccountDocPurchase.ShowEditWindowEx(dt, ad, null);
            }
            else
            {
                CCriteriaAccountDocSale.ShowEditWindowEx(dt, ad, null);
            }
        }
        private void populateCashType(MAccountDoc d)
        {
            Hashtable hash = new Hashtable();

            hash[(int)AccountDocumentType.AcctDocCashSale]     = "SALE_CASH_CHANGE_TYPE";
            hash[(int)AccountDocumentType.AcctDocArReceipt]    = "SALE_DEBT_CHANGE_TYPE";
            hash[(int)AccountDocumentType.AcctDocCashPurchase] = "PURCHASE_CASH_CHANGE_TYPE";
            hash[(int)AccountDocumentType.AcctDocApReceipt]    = "PURCHASE_DEBT_CHANGE_TYPE";

            if (d.PaymentItems.Count > 0)
            {
                return;
            }

            int    dt  = CUtil.StringToInt(d.DocumentType);
            String key = (String)hash[dt];

            d.ChangeType = "1"; // CGlobalVariable.GetGlobalVariableValue(key); - ปิด feature ทอนด้วยเครดิต
        }