Пример #1
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));
        }
Пример #2
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);
        }