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();
        }
示例#2
0
        protected override MBaseModel createObject()
        {
            MCheque av = (MCheque)loadParam.ActualView;

            MCheque mv = new MCheque(new CTable(""));

            mv.CreateDefaultValue();
            mv.ChequeDate = DateTime.Now;
            mv.Direction  = loadParam.GenericType;

            if (av != null)
            {
                //Default value
                mv.EntityObj    = av.EntityObj;
                mv.PayeeName    = av.PayeeName;
                mv.ChequeAmount = av.ChequeAmount;
            }

            mv.IssueDate     = DateTime.Now;
            mv.ChequeDate    = DateTime.Now;
            mv.ChequeStatus  = ((int)InventoryDocumentStatus.InvDocPending).ToString();
            mv.IsAcPayeeOnly = true;
            mv.AllowNegative = CGlobalVariable.IsCashNegativeAllow();

            return(mv);
        }
示例#3
0
        private void LoadData()
        {
            isInLoad   = true;
            this.Title = Caption;
            lkup.Focus();

            CTable t = new CTable("");

            vw = new MAccountDocItem(t);
            vw.CreateDefaultValue();

            DataContext = vw;

            CUtil.EnableForm(false, this);

            if (Mode.Equals("E"))
            {
                CTable newDB = actualView.GetDbObject().Clone();
                vw.SetDbObject(newDB);

                lkup.Lookup = selectionTypeToLookup(vw.SelectType);

                vw.NotifyAllPropertiesChanged();
            }
            else
            {
                vw.SelectType = CGlobalVariable.GetGlobalVariableValue("DEFAULT_SELECTION_TYPE_PERCHASE");
                lkup.Lookup   = selectionTypeToLookup(vw.SelectType);
            }

            vw.IsModified = false;
            CUtil.EnableForm(true, this);
            isInLoad = false;
        }
        private void LoadData()
        {
            //isInLoad = true;
            this.Title = Caption;

            CTable t = new CTable("");

            vw = new MPaymentCriteria(t);
            vw.CreateDefaultValue();

            DataContext = vw;

            CUtil.EnableForm(false, this);

            if (Mode.Equals("E"))
            {
                CTable newDB = actualView.GetDbObject().Clone();
                vw.SetDbObject(newDB);
            }
            else
            {
                vw.VatPercent = CGlobalVariable.GetGlobalVariableValue("VAT_PERCENTAGE");
                vw.WhPercent  = "3";
            }

            vw.NotifyAllPropertiesChanged();

            vw.IsModified = false;
            CUtil.EnableForm(true, this);
            //isInLoad = false;
        }
        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();
        }
        private Boolean SaveData(String approveFlag)
        {
            if (!CHelper.VerifyAccessRight("GENERAL_VARIABLE_EDIT"))
            {
                return(false);
            }

            //Edit mode, always

            if (vw.IsModified)
            {
                Boolean result = SaveToView();
                if (result)
                {
                    CUtil.EnableForm(false, this);
                    CTable t = OnixWebServiceAPI.UpdateGlobalVariable(vw.GetDbObject());
                    CUtil.EnableForm(true, this);
                    if (t != null)
                    {
                        CGlobalVariable.InitGlobalVariables();

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

            return(true);
        }
示例#7
0
        private void WinMain_OnLoad(object sender, RoutedEventArgs e)
        {
            CConfig.ConfigRead();

            initStatusBar();

            WinLogin wLogin = new WinLogin();

            wLogin.ShowDialog();
            Boolean isOK = wLogin.LoginOK;

            if (isOK)
            {
                stbiUserValue.Content = OnixWebServiceAPI.GetLastUserLogin();
                isLogin = true;

                configureMenu();

                //Load user variables
                if (!OnixWebServiceAPI.UserID().Equals(""))
                {
                    currentUser = new CTable("USER");
                    currentUser.SetFieldValue("USER_ID", OnixWebServiceAPI.UserID());
                    currentUser = OnixWebServiceAPI.GetUserInfo(currentUser);
                    CConfig.LoadLastValueSaved(currentUser);
                }

                CReportFactory.InitReports();
                CMasterReference.LoadCompanyProfile();
                CGlobalVariable.InitGlobalVariables();
                CMasterReference.LoadAllMasterRefItems(OnixWebServiceAPI.GetAllMasterRefList);
                CUtil.ExportLoadingImage();
            }
        }
        private void LoadData()
        {
            isInLoadData = true;

            this.Title = Caption;
            dtDocumentDate.Focus();

            vw.CreateDefaultValue();
            CUtil.EnableForm(false, this);

            if (Mode.Equals("E"))
            {
                CTable m = OnixWebServiceAPI.GetAccountDocInfo(actualView.GetDbObject());
                if (m != null)
                {
                    vw.SetDbObject(m);
                    vw.NotifyAllPropertiesChanged();
                }
            }

            else if (Mode.Equals("A"))
            {
                vw.DocumentDate = DateTime.Now;
                vw.DocumentType = ((int)dt).ToString();

                vw.AllowCashNegative      = CGlobalVariable.IsCashNegativeAllow();
                vw.AllowARAPNegative      = CGlobalVariable.IsArApNegativeAllow();
                vw.AllowInventoryNegative = CGlobalVariable.IsInventoryNegativeAllow();
            }

            vw.IsModified = false;
            isInLoadData  = false;

            CUtil.EnableForm(true, this);
        }
示例#9
0
        private void LoadData()
        {
            isInLoadData = true;

            this.Title = Caption;
            dtFromDate.Focus();

            vw.CreateDefaultValue();

            CUtil.EnableForm(false, this);

            if (Mode.Equals("E"))
            {
                CTable m = getDocInfoWrapper();
                if (m != null)
                {
                    vw.SetDbObject(m);
                    vw.InitAuxilaryDocItem();
                    vw.InitPaymentCriteria();

                    String tmp = vw.EntityAddressID;
                    vw.InitEntityAddresses();
                    vw.EntityAddressID = tmp;

                    tmp = vw.EntityBankAccountID;
                    vw.InitEntityBankAccounts();
                    vw.EntityBankAccountID = tmp;

                    vw.AddressObj = CUtil.MasterIDToObject(vw.EntityAddresses, vw.EntityAddressID);

                    vw.NotifyAllPropertiesChanged();
                }
            }
            else if (Mode.Equals("A"))
            {
                vw.DocumentDate = DateTime.Now;
                vw.VatPct       = CGlobalVariable.GetGlobalVariableValue("VAT_PERCENTAGE");
                vw.VatType      = CGlobalVariable.GetGlobalVariableValue("DEFAULT_VAT_TYPE_PERCHASE");
                vw.NoteWidthCm  = "10.00";
                vw.NoteHeightCm = "7.00";
                vw.NoteTopCm    = "12.00";
                vw.NoteLeftCm   = "1.00";
                vw.IsNoteStick  = false;

                ObservableCollection <MMasterRef> branches = CMasterReference.Instance.Branches;
                if (branches.Count > 1)
                {
                    MMasterRef b = branches[1];
                    cboBranch.SelectedObject = b;
                }

                vw.IsPoInvoiceRefByItem = true;
            }

            vw.IsModified = false;
            isInLoadData  = false;

            CUtil.EnableForm(true, this);
        }
示例#10
0
        protected override MBaseModel createObject()
        {
            MCashDocXfer mv = new MCashDocXfer(new CTable(""));

            mv.CashXferType  = "1";
            mv.DocumentType  = loadParam.GenericType;
            mv.AllowNegative = CGlobalVariable.IsInventoryNegativeAllow();
            mv.DocumentDate  = DateTime.Now;
            mv.CreateDefaultValue();

            return(mv);
        }
        private void LoadData()
        {
            isInLoadData = true;

            this.Title = Caption;
            dtFromDate.Focus();

            vw.CreateDefaultValue();

            CUtil.EnableForm(false, this);

            if (Mode.Equals("E"))
            {
                CTable m = getDocInfoWrapper();
                if (m != null)
                {
                    vw.SetDbObject(m);
                    vw.InitAccountDocItem();
                    vw.InitAccountDocPayment();
                    String tmp = vw.EntityAddressID;
                    vw.InitEntityAddresses();
                    vw.EntityAddressID = tmp;
                    vw.AddressObj      = CUtil.MasterIDToObject(vw.EntityAddresses, vw.EntityAddressID);

                    vw.BillSimulate.InitPromotionItems();
                    vw.BillSimulate.InitSelectedItems();

                    vw.NotifyAllPropertiesChanged();
                }

                vw.IsModified = false;
            }
            else if (Mode.Equals("A"))
            {
                vw.DocumentDate           = DateTime.Now;
                vw.VAT_PCT                = CGlobalVariable.GetGlobalVariableValue("VAT_PERCENTAGE");
                vw.VATType                = CGlobalVariable.GetGlobalVariableValue("DEFAULT_VAT_TYPE_SALE");
                vw.AllowCashNegative      = CGlobalVariable.IsCashNegativeAllow();
                vw.AllowARAPNegative      = CGlobalVariable.IsArApNegativeAllow();
                vw.AllowInventoryNegative = CGlobalVariable.IsInventoryNegativeAllow();

                vw.IsModified = (actualView != null);
            }


            isInLoadData = false;

            CUtil.EnableForm(true, this);
        }
        private void addItemFromPayroll(ArrayList arr, int type)
        {
            String projectVariable = "PAYROLL_PROJECT_CODE";
            String serviceVariable = "PAYROLL_SERVICE_CODE";

            if (type == 2)
            {
                serviceVariable = "SOCIAL_SECURITY_SERVICE_CODE";
            }

            String   projectCode = CGlobalVariable.GetGlobalVariableValue(projectVariable);
            CTable   p           = getObject(projectCode, "PROJECT_CODE", "GetProjectList", "PROJECT_LIST");
            MProject pj          = new MProject(p);

            String   serviceCode = CGlobalVariable.GetGlobalVariableValue(serviceVariable);
            CTable   s           = getObject(serviceCode, "SERVICE_CODE", "GetServiceList", "SERVICE_LIST");
            MService sv          = new MService(s);

            foreach (MVPayrollDocument pd in arr)
            {
                CTable          t   = new CTable("");
                MAccountDocItem mdi = new MAccountDocItem(t);
                mdi.CreateDefaultValue();
                mdi.SelectType = "1";
                mdi.ServiceObj = sv;
                mdi.ProjectObj = pj;

                vw.AddAccountDocItem(mdi);

                MAuxilaryDocSubItem mi = new MAuxilaryDocSubItem(new CTable(""));
                mi.Description = String.Format("{0}-{1} {2}", pd.FromSalaryDateFmt, pd.ToSalaryDateFmt, pd.EmployeeTypeDesc);
                mi.SubItemDate = pd.ToSalaryDate;
                mi.UnitPrice   = pd.ReceiveAmount;

                if (type == 2)
                {
                    mi.UnitPrice = pd.SocialSecurityCompanyAmount;
                }

                mi.Quantity = "1.00";
                mdi.AddItemDetail(mi);

                mdi.CalculateSubItemTotal();
                mdi.SerializeItemDetails();
            }
        }
        private void LoadData()
        {
            isInLoadData = true;

            this.Title = Caption;
            dtFromDate.Focus();

            vw.CreateDefaultValue();

            CUtil.EnableForm(false, this);

            if (Mode.Equals("E"))
            {
                //CTable m = OnixWebServiceAPI.GetAccountDocInfo(actualView.GetDbObject());
                CTable m = getDocInfoWrapper();
                if (m != null)
                {
                    vw.SetDbObject(m);
                    vw.InitAccountDocReceipt();
                    vw.InitAccountDocPayment();
                    String tmp = vw.EntityAddressID;
                    vw.InitEntityAddresses();
                    vw.EntityAddressID = tmp;
                    vw.AddressObj      = CUtil.MasterIDToObject(vw.EntityAddresses, vw.EntityAddressID);

                    vw.NotifyAllPropertiesChanged();
                }
            }
            else if (Mode.Equals("A"))
            {
                vw.DocumentDate           = DateTime.Now;
                vw.VAT_PCT                = CGlobalVariable.GetGlobalVariableValue("VAT_PERCENTAGE");;
                vw.AllowCashNegative      = CGlobalVariable.IsCashNegativeAllow();
                vw.AllowARAPNegative      = CGlobalVariable.IsArApNegativeAllow();
                vw.AllowInventoryNegative = CGlobalVariable.IsInventoryNegativeAllow();
                vw.IsWhPayType1           = true;
            }

            vw.IsModified = false;
            isInLoadData  = false;

            CUtil.EnableForm(true, this);
        }
示例#14
0
        public static MAccountDoc TaxDocToAccountDoc(MVTaxDocument td, UIElement parent)
        {
            MAccountDoc ad = new MAccountDoc(new CTable(""));

            if (td.ChequeID.Equals(""))
            {
                String supplierCode = CGlobalVariable.GetGlobalVariableValue("REVENUE_DEP_SUPPLIER_CODE");
                if (supplierCode.Equals(""))
                {
                    CHelper.ShowErorMessage("REVENUE_DEP_SUPPLIER_CODE", "error_revenue_dep_code_missing", null);
                    return(null);
                }

                MEntity en = new MEntity(new CTable(""));
                en.EntityCode = supplierCode;
                en.Category   = "2";

                CUtil.EnableForm(false, parent);
                ArrayList arr = OnixWebServiceAPI.GetListAPI("GetEntityList", "ENTITY_LIST", en.GetDbObject());
                CUtil.EnableForm(true, parent);

                if ((arr == null) || (arr.Count <= 0))
                {
                    CHelper.ShowErorMessage(supplierCode, "error_supplier_code_missing", null);
                    return(null);
                }

                CTable obj = (CTable)arr[0];
                en.SetDbObject(obj);

                ad.EntityObj  = en;
                ad.EntityName = en.EntityName;
            }
            else
            {
                ad.ChequeID = td.ChequeID;
            }

            ad.IsPopulateChequeAmt = true;

            return(ad);
        }
        private void LoadData()
        {
            isInLoadData = true;

            this.Title = Caption;
            dtFromDate.Focus();

            vw.CreateDefaultValue();

            CUtil.EnableForm(false, this);

            if (Mode.Equals("E"))
            {
                CTable m = getDocInfoWrapper();
                if (m != null)
                {
                    vw.SetDbObject(m);
                    vw.InitAuxilaryDocItem();
                    vw.InitRemarks();
                    quotationType = vw.QuotationType;

                    String tmp = vw.EntityAddressID;
                    vw.InitEntityAddresses();
                    vw.EntityAddressID = tmp;

                    vw.AddressObj = CUtil.MasterIDToObject(vw.EntityAddresses, vw.EntityAddressID);

                    vw.NotifyAllPropertiesChanged();
                }
            }
            else if (Mode.Equals("A"))
            {
                vw.DocumentDate = DateTime.Now;
                vw.VatPct       = CGlobalVariable.GetGlobalVariableValue("VAT_PERCENTAGE");
                vw.VatType      = CGlobalVariable.GetGlobalVariableValue("DEFAULT_VAT_TYPE_PERCHASE");
            }

            vw.IsModified = false;
            isInLoadData  = false;

            CUtil.EnableForm(true, this);
        }
示例#16
0
        public static CTable ApproveChequeFromAccountDoc(MAccountDoc doc)
        {
            CTable dat = new CTable("");

            Boolean approveCheque = CGlobalVariable.GetGlobalVariableValue("CHEQUE_APPROVE_IMMEDIATE_FLAG").Equals("Y");

            if (!approveCheque)
            {
                return(dat);
            }

            dat.SetFieldValue("CHEQUE_ID", doc.ChequeID);

            CTable cheque = OnixWebServiceAPI.SubmitObjectAPI("GetChequeInfo", dat);

            if (cheque != null)
            {
                cheque = OnixWebServiceAPI.SubmitObjectAPI("ApproveCheque", cheque);
            }

            return(cheque);
        }
示例#17
0
        protected override MBaseModel createObject()
        {
            MCashDoc mv = null;

            if (docType == CashDocumentType.CashDocImport)
            {
                mv = new MCashDocIn(new CTable(""));
            }
            else if (docType == CashDocumentType.CashDocExport)
            {
                mv = new MCashDocOut(new CTable(""));
            }

            mv.CreateDefaultValue();
            mv.DocumentDate   = DateTime.Now;
            mv.DocumentType   = ((Int32)docType).ToString();
            mv.IsInternalDoc  = false;
            mv.DocumentStatus = ((int)CashDocumentStatus.CashDocPending).ToString();
            mv.AllowNegative  = CGlobalVariable.IsCashNegativeAllow();

            return(mv);
        }
示例#18
0
        private void LoadData()
        {
            //isInLoadData = true;

            this.Title = Caption;
            txtKey.Focus();

            vw.CreateDefaultValue();

            CUtil.EnableForm(false, this);

            if (Mode.Equals("E"))
            {
                CTable m = OnixWebServiceAPI.GetBranchConfigInfo(actualView.GetDbObject());
                if (m != null)
                {
                    vw.SetDbObject(m);
                    vw.InitBranchPOSs();
                    vw.NotifyAllPropertiesChanged();
                }
            }
            else if (Mode.Equals("A"))
            {
                vw.DocNoCashPattern   = CGlobalVariable.GetGlobalVariableValue("DOC_NO_CASH_DEFAULT");
                vw.DocNoDebtPattern   = CGlobalVariable.GetGlobalVariableValue("DOC_NO_DEBT_DEFAULT");
                vw.DocNoCashNVPattern = CGlobalVariable.GetGlobalVariableValue("DOC_NO_CASH_DEFAULT_NV");
                vw.DocNoDebtNVPattern = CGlobalVariable.GetGlobalVariableValue("DOC_NO_DEBT_DEFAULT_NV");

                String SeqLength = CGlobalVariable.GetGlobalVariableValue("DOC_SEQ_LENGTH_DEFAULT");
                vw.DocNoCashSeqLength   = SeqLength;
                vw.DocNoDebtSeqLength   = SeqLength;
                vw.DocNoCashNVSeqLength = SeqLength;
                vw.DocNoDebtNVSeqLength = SeqLength;

                String YearOffset = CGlobalVariable.GetGlobalVariableValue("DOC_NO_YEAR_OFFSET_DEFAULT");
                vw.DocNoCashYearOffset   = YearOffset;
                vw.DocNoDebtYearOffset   = YearOffset;
                vw.DocNoCashNVYearOffset = YearOffset;
                vw.DocNoDebtNVYearOffset = YearOffset;

                String Reset = CGlobalVariable.GetGlobalVariableValue("DOC_NO_RESET_DEFAULT");
                if (Reset.Equals("2"))
                {
                    vw.IsCashVatResetByYear   = true;
                    vw.IsDebtVatResetByYear   = true;
                    vw.IsCashNoVatResetByYear = true;
                    vw.IsDebtNoVatResetByYear = true;
                }
                else if (Reset.Equals("1"))
                {
                    vw.IsCashVatResetByMonth   = true;
                    vw.IsDebtVatResetByMonth   = true;
                    vw.IsCashNoVatResetByMonth = true;
                    vw.IsDebtNoVatResetByMonth = true;
                }

                //String Account = CGlobalVariable.GetGlobalVariableValue("SALE_PETTY_CASH_ACCT_NO");
                //CUtil.LoadCashAccount(cboAccountVat, true, Account);
                //CUtil.LoadMasterRefCombo(cboBranch, true, MasterRefEnum.MASTER_BRANCH, branchID);
            }

            vw.IsModified = false;
            //isInLoadData = false;

            CUtil.EnableForm(true, this);
        }