private Boolean loadLastBill()
        {
            String bsimID = CConfig.GetParamValue("LAST_BILL_SIMULATE_ID");

            if (bsimID.Equals(""))
            {
                CConfig.AddParam("LAST_BILL_SIMULATE_ID", "");
                return(false);
            }

            billSim.BillSimulateID = bsimID;
            CUtil.EnableForm(false, this);
            CTable rtn = OnixWebServiceAPI.GetBillSimulateInfo(billSim.GetDbObject());

            CUtil.EnableForm(true, this);
            if (rtn != null)
            {
                billSim.SetDbObject(rtn);
                billSim.InitSelectedItems();
                billSim.NotifyAllPropertiesChanged();

                return(true);
            }

            billSim.BillSimulateID = "";
            return(false);
        }
        private void cmdSave_Click(object sender, RoutedEventArgs e)
        {
            Boolean result = SaveToView();

            if (!result)
            {
                return;
            }

            String errCd = "";

            CUtil.EnableForm(false, this);
            if (billSim.BillSimulateID.Equals(""))
            {
                //Add mode
                billSim.DocumentType   = "1";
                billSim.DocumentStatus = "1";
                billSim.DocumentNo     = CUtil.DateTimeToDateStringInternal(DateTime.Now);
                billSim.SimulationFlag = "Y";
                CTable rtn = OnixWebServiceAPI.CreateBillSimulate(billSim.GetDbObject());
                if (rtn != null)
                {
                    billSim.SetDbObject(rtn);
                    billSim.InitSelectedItems();
                    billSim.IsModified = false;
                    CUtil.EnableForm(true, this);

                    CConfig.AddParam("LAST_BILL_SIMULATE_ID", billSim.BillSimulateID);
                    return;
                }

                errCd = "ERROR_USER_ADD";
            }
            else
            {
                //Edit mode
                CTable rtn = OnixWebServiceAPI.UpdateBillSimulate(billSim.GetDbObject());
                if (rtn != null)
                {
                    billSim.IsModified = false;
                    CUtil.EnableForm(true, this);

                    return;
                }

                errCd = "ERROR_USER_EDIT";
            }

            CUtil.EnableForm(true, this);

            //Error here
            CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), errCd, null);
            return;
        }
        private void cmdSearch_Click(object sender, RoutedEventArgs e)
        {
            CCriteriaBillSimulate cr = new CCriteriaBillSimulate();

            cr.SetActionEnable(false);
            cr.Init("");

            WinLookupSearch2 w = new WinLookupSearch2(cr, Caption);

            w.ShowDialog();
            if (w.IsOK)
            {
                MBillSimulate bs = (MBillSimulate)w.ReturnedObj;
                CConfig.AddParam("LAST_BILL_SIMULATE_ID", bs.BillSimulateID);
                loadLastBill();

                billSim.IsModified = false;
            }
        }