Exemplo n.º 1
0
        private string GetSqno(DateTime date, string tpid, string sqid)
        {
            //像是在計算 該日 該類 的傳票有幾張...//
            this.db = new GWEB_TESTEntities();
            string result = "";

            try
            {
                var queryResult =
                    this.db.ACBD.Where(x =>
                                       x.DATE == date &&
                                       x.TPID == tpid
                                       //&& x.SQID == sqid//
                                       ).Count();
                string temp = queryResult.ToString().PadLeft(3, '0');
                result = temp.Substring(temp.Length - 1, -3);
            }
            catch (Exception)
            {
                //TODO:
                throw;
            }
            finally { db.Dispose(); }
            return(result);
        }
Exemplo n.º 2
0
        public ActionResult QueryACHD_SQID(ACHD model)
        {
            //查詢傳票號碼//
            string result = string.Empty;

            this.db = new GWEB_TESTEntities();
            try
            {
                var queryResult = (from p in db.ACHD
                                   where
                                   p.DATE.Year == model.DATE.Year &&
                                   p.DATE.Month == model.DATE.Month &&
                                   p.TPID == model.TPID
                                   select p).Count();
                string SQID = (queryResult + 1).ToString("000");
                result = (model.DATE.Year - 1911).ToString() + model.DATE.Month.ToString("00") + SQID;
            }
            catch (Exception)
            {
                //TODO:
                throw;
            }
            finally { db.Dispose(); }
            return(Json(new { data = result }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult QueryITNM(ACIT model)
        {
            string result = string.Empty;

            this.db = new GWEB_TESTEntities();
            try
            {
                var queryResult = (from p in db.ACIT
                                   where p.ACID == model.ACID &&
                                   p.SBID == model.SBID &&
                                   p.ITID == model.ITID
                                   select p.ITNM).FirstOrDefault();
                if (queryResult != null)
                {
                    result = queryResult.ToString();
                }
                else
                {
                    result = string.Empty;
                }
            }
            catch (Exception)
            {
                //TODO:
                throw;
            }
            finally { db.Dispose(); }
            return(Json(new { data = result }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult QueryLatestTic_C(ACMS model)
        {
            string result = string.Empty;

            this.db = new GWEB_TESTEntities();
            try
            {
                var queryResult = (from p in db.ACHD where p.TPID == "轉帳" select p).OrderByDescending(p => p.DATE).OrderByDescending(q => q.SQID).Take(1).FirstOrDefault();
                if (queryResult != null)
                {
                    result = string.Format("轉帳: {0} - {1}", queryResult.SQID, queryResult.DATE.Day.ToString("00"));
                }
                else
                {
                    result = string.Empty;
                }
            }
            catch (Exception)
            {
                //TODO:
                throw;
            }
            finally { db.Dispose(); }
            return(Json(new { data = result }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        //[ValidateAntiForgeryToken]
        public string QueryACBJ(PageInfoModel pgingModel, ACBJViewModel model)
        {
            string result = string.Empty;

            this.db = new GWEB_TESTEntities();

            try
            {
                //PAGING//
                //var queryResult = (from p in db.ACBJ select p).OrderBy(x => x.TPID).Skip(pgingModel.PageNum * pgingModel.PageSize).Take(pgingModel.PageSize);

                //NO PAGING//
                var queryResult = (from p in db.ACBJ select p);

                //FILTER ONLY WITH PRIMARY K,.. NOT REALLY EXACTLY/FULLY RIGHT//
                if (model.TPID != "" & model.TPID != null)
                {
                    queryResult = queryResult.Where(x => x.TPID == model.TPID);
                }

                if (model.SQID != "" & model.SQID != null)
                {
                    queryResult = queryResult.Where(x => x.SQID == model.SQID);
                }

                if (model.ACID != "" & model.ACID != null)
                {
                    queryResult = queryResult.Where(x => x.ACID == model.ACID);
                }

                if (model.SBID != "" & model.SBID != null)
                {
                    queryResult = queryResult.Where(x => x.SBID == model.SBID);
                }

                if (model.SQNO != "" & model.SQNO != null)
                {
                    queryResult = queryResult.Where(x => x.SQNO == model.SQNO);
                }

                if (model.PJID != "" & model.PJID != null)
                {
                    queryResult = queryResult.Where(x => x.PJID == model.PJID);
                }

                if (model.PJSQ != "" & model.PJSQ != null)
                {
                    queryResult = queryResult.Where(x => x.PJSQ == model.PJSQ);
                }

                result = new JavaScriptSerializer().Serialize(queryResult.ToList());
            }
            catch (Exception)
            {
                //TODO:
                throw;
            }
            finally { db.Dispose(); }
            return(result);
        }
Exemplo n.º 6
0
        //[ValidateAntiForgeryToken]
        public string QueryACBD(PageInfoModel pgingModel, ACBDViewModel model)
        {
            string result = string.Empty;

            this.db = new GWEB_TESTEntities();
            try
            {
                //PAGING//
                //var queryResult = (from p in db.ACBD select p).OrderBy(x => x.ACID).Skip(pgingModel.PageNum * pgingModel.PageSize).Take(pgingModel.PageSize);

                //NOPAGING//
                var queryResult = (from p in db.ACBD select p);

                if (model.ACID != "" & model.ACID != null)
                {
                    queryResult = queryResult.Where(x => x.ACID == model.ACID);
                }

                if (model.TPID != "" & model.TPID != null)
                {
                    queryResult = queryResult.Where(x => x.TPID == model.TPID);
                }

                if (model.SQID != "" & model.SQID != null)
                {
                    queryResult = queryResult.Where(x => x.SQID == model.SQID);
                }

                if (model.SBID != "" & model.SBID != null)
                {
                    queryResult = queryResult.Where(x => x.SBID == model.SBID);
                }

                if (model.DATE != "" & model.DATE != null)
                {
                    queryResult = queryResult.Where(x => x.DATE == Convert.ToDateTime(model.DATE));
                }
                //queryResult = queryResult.Where(x => x.DATE == DateTime.ParseExact(model.DATE, "yyyyMMdd", null));

                if (model.SQNO != "" & model.SQNO != null)
                {
                    queryResult = queryResult.Where(x => x.SQNO == model.SQNO);
                }

                if (model.CAMT != null)
                {
                    queryResult = queryResult.Where(x => x.CAMT == model.CAMT);
                }

                if (model.DAMT != null)
                {
                    queryResult = queryResult.Where(x => x.DAMT == model.DAMT);
                }

                if (model.TPNM != "" & model.TPNM != null)
                {
                    queryResult = queryResult.Where(x => x.TPNM == model.TPNM);
                }

                if (model.YYMM != "" & model.YYMM != null)
                {
                    queryResult = queryResult.Where(x => x.YYMM == model.YYMM);
                }

                if (model.ITID != "" & model.ITID != null)
                {
                    queryResult = queryResult.Where(x => x.ITID == model.ITID);
                }

                result = new JavaScriptSerializer().Serialize(queryResult.ToList());
            }
            catch (Exception)
            {
                //TODO:
                throw;
            }
            finally { db.Dispose(); }
            return(result);
        }
Exemplo n.º 7
0
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit(EditViewModel model)
        //{
        //    EditViewModel outputModel = new VoucherViewModel();
        //    //this.db = new GWEB_TESTEntities();
        //    //ACHD achd = new ACHD();
        //    //achd.ACID = model.ACID;
        //    //achd.CKAM = Convert.ToDecimal(model.CKAM);
        //    //achd.CKID = model.CKID;
        //    //achd.CKYM = model.CKYM;
        //    //achd.DATE = model.DATE;
        //    //achd.JSKD = model.JSKD;
        //    //achd.NIKD = model.NIKD;
        //    //achd.NOTE = model.NOTE;
        //    //achd.PSID = model.PSID;
        //    //achd.REM1 = model.REM1;
        //    //achd.REM2 = model.REM2;
        //    //achd.SBID = model.SBID;
        //    //achd.SQID = model.SQID;
        //    //achd.TPID = model.TPID;
        //    //achd.TPNM = model.TPNM;
        //    //achd.YYMM = model.YYMM;
        //    //db.ACHD.Add(achd);
        //    //db.SaveChanges();
        //    return View(outputModel);
        //}

        //Query ACHD >> using ACHD MODEL//
        //[ValidateAntiForgeryToken]
        //[NonAction]
        public string QueryACHD(PageInfoModel pgingModel, ACHDViewModel model)
        {
            string result = string.Empty;

            this.db = new GWEB_TESTEntities();
            try
            {
                //PAGING//
                //var queryResult = (from p in db.ACHD select p).OrderBy(x=>x.ACID).Skip(pgingModel.PageNum * pgingModel.PageSize).Take(pgingModel.PageSize);

                //NO PAGING//
                var queryResult = (from p in db.ACHD select p);

                if (model.ACID != "" & model.ACID != null)
                {
                    queryResult = queryResult.Where(x => x.ACID == model.ACID);
                }

                if (model.CKAM != "" & model.CKAM != null)
                {
                    //decimal ckam = 0m;
                    //if (Decimal.TryParse(model.CKAM, out ckam))
                    //{
                    //   queryResult = queryResult.Where(x => x.CKAM == ckam);
                    queryResult = queryResult.Where(x => x.CKAM == Convert.ToDecimal(model.CKAM));
                    //}
                    //else
                    //{
                    //    //TODO:
                    //    //NOTHING//
                    //}
                }

                if (model.CKID != "" & model.CKID != null)
                {
                    queryResult = queryResult.Where(x => x.CKID == model.CKID);
                }

                if (model.CKYM != "" & model.CKYM != null)
                {
                    queryResult = queryResult.Where(x => x.CKYM == model.CKYM);
                }


                if (model.DATE != "" & model.DATE != null)
                {
                    DateTime date = CcDevConst.DATEINIVALUE;
                    if (DateTime.TryParse(model.DATE, out date))
                    {
                        queryResult = queryResult.Where(x => x.DATE == date);
                    }
                    else
                    {
                        //TODO:
                        //NOTHING//
                    }
                }

                if (model.JSKD != "" & model.JSKD != null)
                {
                    queryResult = queryResult.Where(x => x.JSKD == model.JSKD);
                }

                if (model.NIKD != "" & model.NIKD != null)
                {
                    queryResult = queryResult.Where(x => x.NIKD == model.NIKD);
                }

                if (model.NOTE != "" & model.NOTE != null)
                {
                    queryResult = queryResult.Where(x => x.NOTE == model.NOTE);
                }

                if (model.PSID != "" & model.PSID != null)
                {
                    queryResult = queryResult.Where(x => x.PSID == model.PSID);
                }

                if (model.REM1 != "" & model.REM1 != null)
                {
                    queryResult = queryResult.Where(x => x.REM1 == model.REM1);
                }

                if (model.REM2 != "" & model.REM2 != null)
                {
                    queryResult = queryResult.Where(x => x.REM2 == model.REM2);
                }

                if (model.SBID != "" & model.SBID != null)
                {
                    queryResult = queryResult.Where(x => x.SBID == model.SBID);
                }

                if (model.SQID != "" & model.SQID != null)
                {
                    queryResult = queryResult.Where(x => x.SQID == model.SQID);
                }

                if (model.TPID != "" & model.TPID != null)
                {
                    queryResult = queryResult.Where(x => x.TPID == model.TPID);
                }

                if (model.TPNM != "" & model.TPNM != null)
                {
                    queryResult = queryResult.Where(x => x.TPNM == model.TPNM);
                }

                if (model.YYMM != "" & model.YYMM != null)
                {
                    queryResult = queryResult.Where(x => x.YYMM == model.YYMM);
                }

                result = new JavaScriptSerializer().Serialize(queryResult.OrderBy(x => x.TPID).OrderBy(x => x.SQID).ToList());
            }
            catch (Exception)
            {
                //TODO:
                throw;
            }
            finally { db.Dispose(); }

            return(result);
        }
Exemplo n.º 8
0
        private RModel createVoucher(ACHD achd, List <ACBD> acbdList, List <ACBJ> acbjList)
        {
            //for (int i = 0; i < acbdList.Count(); i++)
            //{
            //    if (acbdList[i].SQNO == null || acbdList[i].SQNO == "")
            //    {
            //        acbdList[i].SQNO = (i + 1).ToString();
            //    };
            //}
            //for (int i = 0; i < acbjList.Count(); i++)
            //{
            //    acbjList[i].SQNO = (i + 1).ToString();
            //}
            RModel rModel = new RModel(false, 1, string.Empty);

            this.db = new GWEB_TESTEntities();
            try
            {
                //if (achd.TPID == "現入" && achd.TPID == "現出")

                //{
                //    achd.SBID = "1103";

                //}
                //this.db.ACSB.Where(p=>p. == "")
                this.db.ACHD.Add(achd);
                if (acbdList.Count() > 0)
                {
                    foreach (var item in acbdList)
                    {
                        if (item.SBID == null || item.SBID == "")
                        {
                            item.SBID = "";
                        }
                    }
                    this.db.ACBD.AddRange(acbdList);
                }

                acbjList.RemoveAll(p =>
                                   p.PJID == "" &&
                                   p.CAMT == null &&
                                   p.DAMT == null &&
                                   p.IVAM == null &&
                                   p.IVID == ""
                                   );
                if (acbjList.Count() > 0)
                {
                    acbjList.ForEach(x => {
                        x.DATE = achd.DATE;
                        x.SQID = achd.SQID;
                        x.TPID = achd.TPID;

                        //TT://錯誤資料測試中...//
                        //TODO:...
                        //x.PJID = model.ACID;
                        //x.PJSQ = model.ACID;
                    });
                    this.db.ACBJ.AddRange(acbjList);
                }
                db.SaveChanges();
                rModel.Code    = 0;
                rModel.Success = true;
                rModel.Msg     = string.Empty;
            }
            catch (Exception ex)
            {
                rModel.Code    = 1;
                rModel.Success = false;
                rModel.Msg     = ex.Message;

                //TODO:
                throw;
            }
            finally { db.Dispose(); }
            return(rModel);
        }