示例#1
0
        private void showSalePurchaseHistoryWindow(String category, String selectType, String langKey)
        {
            MSalePurchaseHistory h = new MSalePurchaseHistory(new CTable(""));

            if (selectType.Equals("2"))
            {
                h.ItemCode = this.txtCode.Text;
            }
            else
            {
                //1=Service
                h.ServiceCode = this.txtCode.Text;
            }
            h.Category      = category;
            h.SelectionType = selectType;

            //ObservableCollection<MBaseModel> arr = new ObservableCollection<MBaseModel>();

            Criteria.CCriteriaSalePurchaseHistory cr = new Criteria.CCriteriaSalePurchaseHistory();
            cr.SetActionEnable(false);
            cr.SetDefaultData(h);
            cr.Init(category);

            String caption = CLanguage.getValue(langKey);

            WinLookupSearch1 w = new WinLookupSearch1(cr, caption);

            w.ShowDialog();
        }
        public override Tuple <CTable, ObservableCollection <MBaseModel> > QueryData()
        {
            //MSalePurchaseHistory mp = model as MSalePurchaseHistory;
            //mp.Category = eType;

            CTable tb = model.GetDbObject();

            items = OnixWebServiceAPI.GetSalePurchaseHistoryList(tb);
            lastObjectReturned = OnixWebServiceAPI.GetLastObjectReturned();

            itemSources.Clear();
            int idx = 0;

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

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

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

            return(tuple);
        }
        private String getSelectKeyMap(String name)
        {
            MSalePurchaseHistory d = (MSalePurchaseHistory)GetDefaultData();
            String selectionType   = d.SelectionType;

            Hashtable map = new Hashtable();

            map["pcode"]  = 0;
            map["pname"]  = 1;
            map["pfcode"] = 2;
            map["pfname"] = 3;

            String[] arr1 = { "service_code", "service_name", "ServiceCode", "ServiceName" };
            String[] arr2 = { "item_code", "item_name_thai", "ItemCode", "ItemNameThai" };

            String[] arr = arr1;
            if (selectionType.Equals("2"))
            {
                arr = arr2;
            }

            int    idx = (int)map[name];
            String key = arr[idx];

            return(key);
        }
        private void createCriteriaEntries()
        {
            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_LABEL, "", "from_date"));
            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_DATE_MIN, "FromDocumentDate", ""));

            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_LABEL, "", "to_date"));
            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_DATE_MAX, "ToDocumentDate", ""));

            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_LABEL, "", getCategoryKeyMap("ecode")));
            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_TEXT_BOX, "EntityCode", ""));

            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_LABEL, "", getCategoryKeyMap("ename")));
            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_TEXT_BOX, "EntityName", ""));

            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_LABEL, "", getSelectKeyMap("pcode")));
            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_TEXT_BOX, getSelectKeyMap("pfcode"), ""));

            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_LABEL, "", getSelectKeyMap("pname")));
            AddCriteriaControl(new CCriteriaEntry(CriteriaEntryType.ENTRY_TEXT_BOX, getSelectKeyMap("pfname"), ""));

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

            if (d != null)
            {
                m.ServiceCode   = d.ServiceCode;
                m.ItemCode      = d.ItemCode;
                m.Category      = d.Category;
                m.SelectionType = d.SelectionType;
            }
        }
        private String getCategoryKeyMap(String name)
        {
            MSalePurchaseHistory d = (MSalePurchaseHistory)GetDefaultData();
            String category        = d.Category;

            Hashtable map = new Hashtable();

            map["ecode"] = 0;
            map["ename"] = 1;

            String[] arr1 = { "customer_code", "customer_name" };
            String[] arr2 = { "supplier_code", "supplier_name" };

            String[] arr = arr1;
            if (category.Equals("2"))
            {
                arr = arr2;
            }

            int    idx = (int)map[name];
            String key = arr[idx];

            return(key);
        }