示例#1
0
        public ActionResult GetWH()
        {
            using (DLSMEntities context = new DLSMEntities())
            {
                //find staff in warehouse
                var SessionwhID   = Session["UserWhID"].ToString();
                var SessionUserID = Session["UserID"].ToString();
                var wh            = (from s in context.Staffs
                                     join st in context.StaffWarehouses on s.ID equals st.StID
                                     join w in context.Warehouses on st.WhID equals w.ID
                                     where s.ID.ToString() == SessionUserID
                                     select new
                {
                    ID = st.WhID,
                    Name = w.Name
                }).ToList();

                return(Json(wh));
            }
        }
示例#2
0
        public ActionResult SendApprove(Document model)
        {
            Document w = db.Documents.Where(p => (p.DocNo == model.DocNo) && (p.ID != model.ID)).FirstOrDefault();

            if (w != null)
            {
                return(Json("เลขที่เอกสาร นี้มีอยู่แล้วในระบบ"));
            }
            //Update Status
            var context = new DLSMEntities();
            var upd     = (from d in context.Documents
                           where d.ID == model.ID
                           select d).ToList().SingleOrDefault();

            upd.Status = model.Status;

            context.SaveChanges();

            return(Json("success"));
        }
        public ActionResult Create(Category category)
        {
            var      context = new DLSMEntities();
            Category c       = context.Categories.Where(p => p.Code == category.Code || p.Name == category.Name).FirstOrDefault();

            if (c != null)
            {
                // Cannot delete becasue Topic group is using another process
                //TempData["Msg"] = "รหัส หรือ ชื่อกลุ่มวัสดุอุปกรณ์นี้มีอยู่แล้วในระบบ";
                return(Json("รหัส หรือ ชื่อกลุ่มวัสดุนี้มีอยู่แล้วในระบบ"));
            }
            else
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(Json("success"));
            }

            //return RedirectToAction("Index");
        }
示例#4
0
        // GET: Receives
        public ActionResult Index()
        {
            if (null != TempData["Msg"])
            {
                ViewBag.Msg = TempData["Msg"].ToString();
            }
            var             context  = new DLSMEntities();
            int             Userwhid = Convert.ToInt32(Session["UserWhID"]);
            List <Document> list     = new List <Document>();
            var             listdata = context.sp_DocumentList(Userwhid, "1").ToList();

            if (listdata.Count() > 0)
            {
                foreach (var i in listdata)
                {
                    Document d = new Document();
                    d.ID            = i.ID;
                    d.DocNo         = i.DocNo;
                    d.DocDate       = i.DocDate.Value.AddYears(543);
                    d.CreateBy      = i.CreateBy;
                    d.CreateName    = i.CreateName;
                    d.WhID          = i.WhID;
                    d.WarehouseName = i.WarehouseName;
                    d.PdID          = i.SpID;
                    d.ProductName   = i.ProductName;
                    d.Remark        = i.Remark;
                    d.Status        = i.Status;
                    d.StatusName    = GetStatusName(i.Status);
                    d.ApproveDate   = i.ApproveDate;
                    d.ApproveBy     = i.ApproveBy;
                    d.ProcessDate   = i.ProcessDate;
                    d.ProcessBy     = i.ProcessBy;
                    d.Qty           = i.Qty;
                    list.Add(d);
                }
            }
            ViewBag.WarehouseList = db.Warehouses.ToList();
            ViewBag.ProductList   = db.Products.ToList();

            return(View(list));
        }
示例#5
0
        public ActionResult GetWH()
        {
            using (DLSMEntities context = new DLSMEntities())
            {
                //find staff in warehouse
                var SessionwhID   = Session["UserWhID"].ToString();
                var SessionUserID = Session["UserID"].ToString();
                var wh            = db.sp_WarehouseAuthority(Convert.ToInt32(SessionUserID)).ToList();
                //var wh = (from s in context.Staffs
                //             join st in context.StaffWarehouses on s.ID equals st.StID
                //             join w in context.Warehouses on st.WhID equals w.ID
                //             where s.ID.ToString() == SessionUserID
                //             select new
                //             {
                //                 ID = st.WhID,
                //                 Name = w.Name
                //             }).ToList();

                return(Json(wh));
            }
        }
示例#6
0
        public ActionResult SearchWarehouse(String SearchText)
        {
            var context        = new DLSMEntities();
            var sessionstaffid = Convert.ToInt32(Session["UserID"]);
            List <Warehouse> w = new List <Warehouse>();
            var result         = db.sp_WarehouseSearch(sessionstaffid, SearchText).ToList();

            foreach (var i in result)
            {
                Warehouse warehouse = new Warehouse();
                warehouse.ID     = i.ID;
                warehouse.Code   = i.Code;
                warehouse.Name   = i.Name;
                warehouse.TelNo  = i.TelNo;
                warehouse.Email  = i.Email;
                warehouse.IsMain = i.IsMain;
                w.Add(warehouse);
            }

            return(View("Index", w));
        }
示例#7
0
        public ActionResult DeleteConfirmed(int id)
        {
            var            context = new DLSMEntities();
            DocumentDetail st      = context.DocumentDetails.Where(p => p.PdID == id).FirstOrDefault();

            if (st != null)
            {
                // Cannot delete becasue Topic group is using another process
                TempData["Msg"] = "ลบไม่ได้ เนื่องจากข้อมูลนี้มีการถูกใช้งานอยู่";
                return(RedirectToAction("Edit", new { id = id, ViewBag.Msg }));
            }
            else
            {
                Product product = db.Products.Find(id);
                db.Products.Remove(product);
                db.SaveChanges();
                TempData["Msg"] = "ลบข้อมูลเรียบร้อยแล้ว";
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Search(int?searchWare)
        {
            var context = new DLSMEntities();

            var sessionstaffid   = Convert.ToInt32(Session["UserID"]);
            List <WorkStation> w = new List <WorkStation>();
            var result           = db.sp_WorkStationSearch(sessionstaffid, searchWare).ToList();

            foreach (var i in result)
            {
                WorkStation workstation = new WorkStation();
                workstation.ID          = i.ID;
                workstation.Name        = i.Name;
                workstation.PrinterName = i.PrinterName;
                workstation.Remark      = i.Remark;
                w.Add(workstation);
            }
            ViewBag.WarehouseList = db.Warehouses.ToList();

            return(View("Index", w));
        }
示例#9
0
        public ActionResult checkIsAssetSNControl(int PrdID)
        {
            string isAsset         = "n";
            string isControlSerial = "n";

            using (DLSMEntities context = new DLSMEntities())
            {
                Product objProduct = db.Products.Find(PrdID);   //context.Products.Where(o => o.ID == PrdID).SingleOrDefault();

                if (null != objProduct)
                {
                    // IsAssetss
                    isAsset = objProduct.IsAsset.ToLower() == "y" ? "y" : "n";

                    // IsSerial Control
                    isControlSerial = objProduct.SerialControl.ToLower() == "y" ? "y" : "n";
                }

                return(this.Json(new { isAsset = isAsset.ToString(), isControlSerial = isControlSerial.ToString() }, JsonRequestBehavior.AllowGet));
            }
        }
示例#10
0
        // GET: Issues
        public ActionResult Index()
        {
            var context = new DLSMEntities();
            var list    = (from i in context.Issues
                           join st in context.Staffs on i.CreateBy equals st.ID
                           join tg in context.TopicGroups on i.TgID equals tg.ID
                           join w in context.Warehouses on i.WhID equals w.ID
                           select new {
                ID = i.ID,
                CreateBy = i.CreateBy,
                CreateName = st.Name,
                CreateDate = i.CreateDate,
                TgID = i.TgID,
                TgName = tg.Name,
                Subject = i.Subject,
                Description = i.Description,
                Status = i.Status,
                WhID = i.WhID,
                WhName = w.Name
            }).AsEnumerable().Select(x => new Issue {
                ID          = x.ID,
                CreateBy    = x.CreateBy,
                CreateName  = x.CreateName,
                CreateDate  = x.CreateDate.Value.AddYears(543),
                TgID        = x.TgID,
                TgName      = x.TgName,
                Subject     = x.Subject,
                Description = x.Description,
                Status      = x.Status,
                WhID        = x.WhID,
                WhName      = x.WhName
            }).ToList();

            foreach (var i in list)
            {
                i.StatusName = GetStatusName(i.Status);
            }
            return(View(list));
        }
示例#11
0
        public ActionResult Create([Bind(Include = "ID,Code,Name,NameEN,TelNo,Email,IsMain,LocationName,Latitude,Longitude,PvID")] Warehouse warehouse)
        {
            if (ModelState.IsValid)
            {
                var       context = new DLSMEntities();
                Warehouse w       = context.Warehouses.Where(p => p.Code.Equals(warehouse.Code) || p.Name.Equals(warehouse.Name)).FirstOrDefault();

                if (w != null)
                {
                    return(Json("รหัส หรือ ชื่อสำนักงานขนส่งนี้มีอยู่แล้วในระบบ"));
                }
                else
                {
                    db.Warehouses.Add(warehouse);
                    db.SaveChanges();

                    int WarehouseID = warehouse.ID;
                    return(Json(WarehouseID));;
                }
            }
            return(View(warehouse));
        }
示例#12
0
        protected String MdmAuthen(Staff UserDetail)
        {
            var userInfo = _mdmServiceWrapper.GetUserInfoAsync(
                new MdmAuthenticationInput(UserDetail.UserLogin, UserDetail.UserPassword)).Result;

            if (userInfo != null)
            {
                using (var _db = new DLSMEntities()) {
                    var storeUserInfo = _mapper.Map <GetUserInfo>(userInfo);
                    _db.GetUserInfoes.Add(storeUserInfo);
                    _db.SaveChanges();
                }
            }

            string retcode = null;

            using (DLSMEntities db = new DLSMEntities())
            {
                try
                {
                    var respget = _mdmServiceWrapper
                                  .GetUserInfoAsync(new MdmAuthenticationInput(UserDetail.UserLogin, passold)).Result;

                    var gui = _mapper.Map <GetUserInfo>(respget);

                    db.GetUserInfoes.Add(gui);
                    db.SaveChanges();

                    retcode = "1";
                }
                catch (Exception ex)
                {
                    retcode = "0";
                    message = "authenUser Result: Error กรุณาติดต่อเจ้าหน้าที่";
                }
            }

            return(retcode);
        }
示例#13
0
        public ActionResult DeleteConfirmed(int id)
        {
            var            context = new DLSMEntities();
            StaffWarehouse st      = context.StaffWarehouses.Where(p => p.WhID == id).FirstOrDefault();
            Stock          s       = context.Stocks.Where(p => p.WhID == id).FirstOrDefault();

            if (st != null || s != null)
            {
                // Cannot delete becasue Topic group is using another process
                TempData["Msg"] = "ลบไม่ได้ เนื่องจากข้อมูลนี้มีการถูกใช้งานอยู่";
                return(RedirectToAction("Edit", new { id = id, ViewBag.Msg }));
            }
            else
            {
                Warehouse warehouse = db.Warehouses.Find(id);
                db.Warehouses.Remove(warehouse);
                db.SaveChanges();
                TempData["Msg"] = "ลบข้อมูลเรียบร้อยแล้ว";
            }

            return(RedirectToAction("Index"));
        }
示例#14
0
        public ActionResult DeleteConfirmed(int id)
        {
            var   context = new DLSMEntities();
            Topic topic   = context.Topics.Where(p => p.TgID == id).FirstOrDefault();


            if (topic != null)
            {
                // Cannot delete becasue Topic group is using another process
                TempData["Msg"] = "ลบไม่ได้ เนื่องจากข้อมูลมีการถูกใช้งานอยู่";
                return(RedirectToAction("Edit", new { id = id, ViewBag.Msg }));
            }
            else
            {
                // Can delete topic group
                TopicGroup topicGroup = db.TopicGroups.Find(id);
                db.TopicGroups.Remove(topicGroup);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
示例#15
0
        public ActionResult DeleteConfirmed(int id)
        {
            var   context = new DLSMEntities();
            Staff st      = context.Staffs.Where(p => p.UgID == id).FirstOrDefault();

            if (st != null)
            {
                // Cannot delete becasue Topic group is using another process
                TempData["Msg"] = "ลบไม่ได้ เนื่องจากข้อมูลนี้มีการถูกใช้งานอยู่";
                return(RedirectToAction("Edit", new { id = id, ViewBag.Msg }));
            }
            else
            {
                db.Permissions.RemoveRange(db.Permissions.Where(x => x.UgID == id));
                db.SaveChanges();

                db.UserGroups.Remove(db.UserGroups.SingleOrDefault(x => x.ID == id));
                db.SaveChanges();
                TempData["Msg"] = "ลบข้อมูลเรียบร้อยแล้ว";
                return(RedirectToAction("Index", new { ViewBag.Msg }));
            }
        }
示例#16
0
        // GET: Permissions
        public ActionResult Index()
        {
            var context = new DLSMEntities();
            var list    = (from u in context.UserGroups
                           //from p in context.Permissions
                           //join m in context.Modules on p.MdCode equals m.Code
                           //join u in context.UserGroups on p.UgID equals u.ID
                           select new {
                UserGroupID = u.ID,
                UserGroupName = u.Name
            }).AsEnumerable().Select(x => new Permission {
                UserGroupID   = x.UserGroupID,
                UserGroupName = x.UserGroupName
            }).ToList();

            if (null != TempData["Msg"])
            {
                ViewBag.Msg = TempData["Msg"].ToString();
            }

            return(View(list));
        }
示例#17
0
        public ActionResult SearchCard(string searchCardNo
                                       , string searchToCardNo
                                       , DateTime?searchBeginDate
                                       , DateTime?searchEndDate)
        {
            var context             = new DLSMEntities();
            int Userid              = Convert.ToInt32(Session["UserID"]);
            List <StockSerial> list = new List <StockSerial>();
            //change store to get only stock serial
            var listdata         = context.sp_SearchCard(Convert.ToString(searchCardNo), Convert.ToString(searchToCardNo), searchBeginDate, searchEndDate).ToList().OrderBy(a => a.SerialBegin);
            int sarch_card_limit = 500;

            if (listdata.Count() > 0)
            {
                //using loop from stock serial begin to end
                foreach (var i in listdata)
                {
                    string sbegin        = i.SerialBegin;
                    UInt64 card_serialno = Convert.ToUInt64(sbegin);
                    for (int n = 0; n < i.SerialCount; n++)
                    {
                        StockSerial s = new StockSerial();
                        s.PdID        = n + 1;
                        s.SerialBegin = card_serialno.ToString();
                        s.WhID        = i.whid;

                        list.Add(s);
                        card_serialno++;
                        //check item not over limit
                        if (n > sarch_card_limit)
                        {
                            break;
                        }
                    }
                }
            }

            return(View("Index", list));
        }
示例#18
0
        public ActionResult Search(DateTime?searchFromDate, DateTime?searchToDate, int?searchWare, int?searchPro, string searchSN)
        {
            var             context  = new DLSMEntities();
            int             Userid   = Convert.ToInt32(Session["UserID"]);
            List <Document> list     = new List <Document>();
            var             listdata = context.sp_SearchDocument(searchSN, searchFromDate, searchToDate, searchWare, searchPro, 4, null, Userid).ToList();

            if (listdata.Count() > 0)
            {
                foreach (var i in listdata)
                {
                    Document d = new Document();
                    d.ID              = i.ID;
                    d.DocNo           = i.DocNo;
                    d.DocDate         = i.DocDate.Value.AddYears(543);
                    d.CreateBy        = i.CreateBy;
                    d.CreateName      = i.CreateName;
                    d.WhID            = i.WhID;
                    d.WarehouseName   = i.WarehouseName;
                    d.ToWhID          = i.ToWhID;
                    d.ToWarehouseName = i.ToWarehouseName;
                    d.PdID            = i.PdID;
                    d.ProductName     = i.ProductName;
                    d.Remark          = i.Remark;
                    d.Status          = i.Status;
                    d.StatusName      = GetStatusName(i.Status);
                    d.ApproveDate     = i.ApproveDate;
                    d.ApproveBy       = i.ApproveBy;
                    d.ProcessDate     = i.ProcessDate;
                    d.ProcessBy       = i.ProcessBy;
                    d.Qty             = i.Qty;
                    list.Add(d);
                }
            }
            ViewBag.WarehouseList = db.Warehouses.ToList();
            ViewBag.ProductList   = db.Products.ToList();
            return(View("Index", list));
        }
示例#19
0
        public ActionResult DeleteConfirmed(int id)
        {
            var      context = new DLSMEntities();
            Document d       = context.Documents.Where(p => p.SpID == id).FirstOrDefault();


            if (d != null)
            {
                // Cannot delete becasue Topic group is using another process
                //TempData["Msg"] = "ลบไม่ได้ เนื่องจากข้อมูลมีการถูกใช้งานอยู่";
                //return RedirectToAction("Edit", new { id = id, ViewBag.Msg });
                return(Json("ลบไม่ได้ เนื่องจากข้อมูลมีการถูกใช้งานอยู่"));
            }
            else
            {
                Supplier supplier = db.Suppliers.Find(id);
                db.Suppliers.Remove(supplier);
                db.SaveChanges();
                TempData["Msg"] = "ลบข้อมูลเรียบร้อยแล้ว";
            }

            return(RedirectToAction("Index"));
        }
示例#20
0
        public ActionResult checkIsAsset(int PrdID)
        {
            string res = "n";

            using (DLSMEntities context = new DLSMEntities())
            {
                var isasset = context.Products.Where(o => o.ID == PrdID).Select(s => s.IsAsset).SingleOrDefault();

                if (null != isasset)
                {
                    if (isasset.ToLower() == "y")
                    {
                        res = "y";
                    }
                    else
                    {
                        res = "n";
                    }
                }
            }

            return(this.Json(res, JsonRequestBehavior.AllowGet));
        }
示例#21
0
        public ActionResult Create([Bind(Include = "ID,Name,UserLogin,UserPassword,UgID,TelNo,Email")] Staff staff)
        {
            DLSMEntities db  = new DLSMEntities();
            Staff        stf = new Staff();

            stf.Name         = staff.Name;
            stf.UserLogin    = staff.UserLogin;
            stf.UserPassword = Hash(staff.UserPassword);
            stf.UgID         = staff.UgID;
            stf.TelNo        = staff.TelNo;
            stf.Email        = staff.Email;


            db.Staffs.Add(stf);
            db.SaveChanges();

            StaffID = stf.ID;

            ViewBag.Warehouselist = new SelectList(db.Warehouses, "ID", "Name");
            ViewBag.UgID          = new SelectList(db.UserGroups, "ID", "Name");
            ViewData["StaffID"]   = StaffID;
            return(View());
        }
        // GET: TransferStaffs
        public ActionResult Index()
        {
            if (null != TempData["Msg"])
            {
                ViewBag.Msg = TempData["Msg"].ToString();
            }

            var context = new DLSMEntities();
            var list    = (from ts in context.TransferStaffs
                           join st in context.Staffs on ts.StID equals st.ID
                           join w in context.Warehouses on ts.FromWhID equals w.ID
                           join wh in context.Warehouses on ts.ToWhID equals wh.ID
                           select new {
                ID = ts.ID,
                StID = ts.StID,
                StName = st.Name,
                FromWhID = ts.FromWhID,
                FromWhName = w.Name,
                ToWhID = ts.ToWhID,
                ToWhName = wh.Name,
                EffectiveDate = ts.EffectiveDate
            }).AsEnumerable().Select(x => new TransferStaff {
                ID            = x.ID,
                StID          = x.StID,
                StName        = x.StName,
                FromWhID      = x.FromWhID,
                FromWhName    = x.FromWhName,
                ToWhID        = x.ToWhID,
                ToWhName      = x.ToWhName,
                EffectiveDate = (x.EffectiveDate.Value.Year < 2400 ? x.EffectiveDate.Value.AddYears(543) : x.EffectiveDate),
            }).ToList();

            ViewBag.StID = db.Staffs.ToList();
            ViewBag.WhID = db.Warehouses.ToList();

            return(View(list));
        }
示例#23
0
        public ActionResult SearchProduct(string SearchText, int?SearchCate)
        {
            var context  = new DLSMEntities();
            var products = (from p in context.Products
                            join c in context.Categories on p.CtID equals c.ID
                            where (p.Name.Contains(SearchText) || SearchText == null) &&
                            (c.ID == SearchCate.Value || SearchCate == null)
                            select new
            {
                ID = p.ID,
                Code = p.Code,
                Name = p.Name,
                CtID = c.ID,
                CategoryName = c.Name,
                MinStock = p.MinStock,
                SerialControl = p.SerialControl,
                IsAsset = p.IsAsset
            }).AsEnumerable().Select(x => new Product
            {
                ID            = x.ID,
                Code          = x.Code,
                Name          = x.Name,
                CtID          = x.CtID,
                CategoryName  = x.CategoryName,
                MinStock      = x.MinStock,
                SerialControl = x.SerialControl,
                IsAsset       = x.IsAsset
            }).ToList();

            List <Category> catelist = db.Categories.ToList();

            ViewBag.CateList = new SelectList(catelist, "ID", "Name");

            //return PartialView("ProductSearch",list);
            return(View("Index", products));
        }
示例#24
0
        public ActionResult Create(Product product)
        {
            var     context = new DLSMEntities();
            Product pp      = context.Products.Where(p => p.Code == product.Code || p.Name == product.Name).FirstOrDefault();

            if (pp != null)
            {
                return(Json("รหัส หรือ ชื่อวัสดุนี้มีอยู่แล้วในระบบ"));
            }
            else
            {
                //bool check = product.SerialControl == "on" ? true : false;
                bool check = product.SerialControl.ToLower() == "true" ? true : false;
                if (check == true)
                {
                    product.SerialControl = "Y";
                }
                else
                {
                    product.SerialControl = "N";
                }
                bool check2 = product.IsAsset.ToLower() == "true" ? true : false;
                if (check2 == true)
                {
                    product.IsAsset = "Y";
                }
                else
                {
                    product.IsAsset = "N";
                }
                product.MinStock = 0;
                db.Products.Add(product);
                db.SaveChanges();
                return(Json("success"));
            }
        }
示例#25
0
        public ActionResult Edit([Bind(Include = "ID,Code,Name,NameEN,TelNo,Email,IsMain,LocationName,Latitude,Longitude,BackgroundPicture,PvID")] Warehouse warehouse)
        {
            if (ModelState.IsValid)
            {
                var       context = new DLSMEntities();
                Warehouse w       = context.Warehouses.Where(p => p.Name.Equals(warehouse.Name) && p.ID != warehouse.ID).FirstOrDefault();

                if (w != null)
                {
                    // Cannot delete becasue Topic group is using another process
                    //TempData["Msg"] = "ชื่อคลังวัสดุอุปกรณ์นี้มีอยู่แล้วในระบบ";
                    //return RedirectToAction("Edit", new { id = warehouse.ID, ViewBag.Msg });
                    return(Json("รหัส หรือ ชื่อสำนักงานขนส่งนี้มีอยู่แล้วในระบบ"));
                }
                else
                {
                    db.Entry(warehouse).State = EntityState.Modified;
                    db.SaveChanges();
                    int WarehouseID = warehouse.ID;
                    return(Json(WarehouseID));
                }
            }
            return(View(warehouse));
        }
示例#26
0
        public ActionResult Edit(Product product)
        {
            var     context = new DLSMEntities();
            Product pp      = context.Products.Where(p => p.Name == product.Name && p.ID != product.ID).FirstOrDefault();

            if (pp != null)
            {
                return(Json("ชื่อวัสดุนี้มีอยู่แล้วในระบบ"));
            }
            else
            {
                bool check = product.SerialControl.ToLower() == "true" ? true : false;
                if (check == true)
                {
                    product.SerialControl = "Y";
                }
                else
                {
                    product.SerialControl = "N";
                }

                bool check2 = product.IsAsset.ToLower() == "true" ? true : false;
                if (check2 == true)
                {
                    product.IsAsset = "Y";
                }
                else
                {
                    product.IsAsset = "N";
                }
                product.MinStock        = 0;
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(Json("success"));
            }
        }
示例#27
0
        public ActionResult Create(Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                var      context = new DLSMEntities();
                Supplier c       = context.Suppliers.Where(p => p.Name == supplier.Name).FirstOrDefault();

                if (c != null)
                {
                    // Cannot delete becasue Topic group is using another process
                    //TempData["Msg"] = "ชื่อผู้จำหน่ายนี้มีอยู่แล้วในระบบ";
                    //return RedirectToAction("Create", new { ViewBag.Msg });
                    return(Json("ชื่อผู้ประกอบการนี้มีอยู่แล้วในระบบ"));
                }
                else
                {
                    db.Suppliers.Add(supplier);
                    db.SaveChanges();
                }
                return(Json("success"));
            }

            return(View(supplier));
        }
示例#28
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                SaveCardRequest parm = new SaveCardRequest();
                using (StreamReader sr = new StreamReader(context.Request.InputStream))
                {
                    String data = sr.ReadToEnd();
                    parm    = new JavaScriptSerializer().Deserialize <SaveCardRequest>(data);
                    cardEIN = parm.CardEIN;
                }

                SaveCardResponse ap = new SaveCardResponse();
                using (DLSMEntities db = new DLSMEntities())
                {
                    db.Database.Connection.Open();

                    using (var dbContextTransaction = db.Database.BeginTransaction())
                    {
                        try
                        {
                            var result = db.sp_ApiSaveCard(parm.addrNo, parm.ampDesc, parm.ampDescEng, parm.birthDateStr, parm.birthFlag,
                                                           parm.distDesc, parm.distDescEng, parm.docNo, parm.docType, parm.reqMasRef, parm.expDateStr,
                                                           parm.fname, parm.fnameEng, parm.issDateStr, parm.issOffLocCode, parm.lane, parm.lname,
                                                           parm.lnameEng, parm.locFullDesc, parm.message, parm.natDesc, parm.offLocDesc, parm.offLocEngDesc,
                                                           parm.offRegDesc, parm.offRegEngDesc, parm.pcNo, parm.pltCode, parm.pltDesc, parm.pltEngDesc,
                                                           parm.pltNo, parm.pltPrnDesc, parm.prevExpDateStr, parm.prevIssDateStr, parm.prevOffLocDesc,
                                                           parm.prevOffRegDesc, parm.prevOffRegEngDesc, parm.prevPltDesc, parm.prevPltNo, parm.prvCode,
                                                           parm.prvDesc, parm.prvDescEng, parm.rcpNo, parm.reqDateStr, parm.reqNo, parm.reqTrDesc,
                                                           parm.sex, parm.soi, parm.street, parm.titleAbrev, parm.titleDesc, parm.titleEngAbrev, parm.villageNo,
                                                           parm.zipCode, parm.alienFlag, parm.ccFlag, parm.DCICode, parm.conditionDesc, parm.organDonateFlag,
                                                           parm.TRSFlag, parm.firstIssueDateStr, parm.pltDescShort, parm.pltNo1, parm.pltNo2, parm.prevPltDescShort,
                                                           parm.prevPltNo1, parm.prevPltNo2, parm.pltNoEng, parm.WH_ID, parm.staffId, parm.workstationId,
                                                           parm.productType, parm.CardEIN, parm.qrCode).ToList();

                            if (result[0].seqno > 0)
                            {
                                db.SaveChanges();
                                dbContextTransaction.Commit();
                                ap.resultCode = "1";
                                ap.cardEIN    = parm.CardEIN;
                                ap.message    = "OK";
                            }
                            else
                            {
                                if (db.Database.Connection != null)
                                {
                                    try
                                    {
                                        dbContextTransaction.Rollback();
                                    }
                                    catch
                                    {
                                    }
                                }

                                ap.cardEIN    = parm.CardEIN;
                                ap.resultCode = "0";
                                ap.message    = "not found";
                            }
                            //dbContextTransaction.Rollback();
                        }
                        catch (Exception ex)
                        {
                            if (db.Database.Connection != null)
                            {
                                try
                                {
                                    dbContextTransaction.Rollback();
                                }
                                catch
                                {
                                }
                            }

                            ap.cardEIN    = parm.CardEIN;
                            ap.resultCode = "0";
                            if (ex.InnerException != null)
                            {
                                ap.message = ex.InnerException.Message;
                                if (ex.InnerException.StackTrace != null)
                                {
                                    ap.message += " + InnerException.StackTrace: " + ex.InnerException.StackTrace;
                                }
                            }
                            if (ex.Message != null)
                            {
                                ap.message += "+" + ex.Message;
                                if (ex.StackTrace != null)
                                {
                                    ap.message += " + StackTrace: " + ex.StackTrace;
                                }
                            }
                            if (ex.InnerException == null && ex.Message == null)
                            {
                                ap.message = "Error: SaveCard catch 2";
                            }

                            ap.message += " (Step 2)";
                            //ap.message = ex.InnerException == null ? (ex.Message == null ? "Error: SaveCard catch 2" : ex.Message) : ex.InnerException.Message + " StackTrace:" + ex.StackTrace;
                        }
                    }
                }
                string json = new JavaScriptSerializer().Serialize(ap);
                context.Response.ContentType = "text/javascript";
                context.Response.Write(json);
            }
            catch (Exception ex)
            {
                SaveCardResponse ap = new SaveCardResponse();
                ap.cardEIN    = cardEIN;
                ap.resultCode = "0";
                if (ex.InnerException != null)
                {
                    ap.message = ex.InnerException.Message;
                    if (ex.InnerException.StackTrace != null)
                    {
                        ap.message += " + InnerException.StackTrace: " + ex.InnerException.StackTrace;
                    }
                }
                if (ex.Message != null)
                {
                    ap.message += "+" + ex.Message;
                    if (ex.StackTrace != null)
                    {
                        ap.message += " + StackTrace: " + ex.StackTrace;
                    }
                }
                if (ex.InnerException == null && ex.Message == null)
                {
                    ap.message = "Error: SaveCard catch 1";
                }
                ap.message += " (Step 1)";

                string json = new JavaScriptSerializer().Serialize(ap);
                context.Response.ContentType = "text/javascript";
                context.Response.Write(json);
            }
        }
示例#29
0
        // GET: Issues/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Issue issue   = db.Issues.Find(id);
            var   context = new DLSMEntities();

            issue.StatusName = GetStatusName(issue.Status);

            if (issue.WhID != null)
            {
                var wh = context.Warehouses.SingleOrDefault(x => x.ID == issue.WhID);
                issue.WhName  = wh.Name;
                issue.WhTelNo = wh.TelNo;
            }

            if (issue.TpID != null)
            {
                var tp = context.Topics.SingleOrDefault(x => x.ID == issue.TpID);
                issue.TpSubject = tp.Subject;
            }

            if (issue.TgID != null)
            {
                var tg = context.TopicGroups.SingleOrDefault(x => x.ID == issue.TgID);
                issue.TgName = tg.Name;
            }

            var st = context.Staffs.SingleOrDefault(x => x.ID == issue.CreateBy);

            issue.CreateName = st.Name;
            issue.StTelNo    = st.TelNo;

            issue.CreateDate = issue.CreateDate.Value.AddYears(543);

            if (issue == null)
            {
                return(HttpNotFound());
            }

            var list = (from c in context.Commends
                        join i in context.Issues on c.IsID equals i.ID
                        where c.IsID == issue.ID
                        select new
            {
                ID = c.ID,
                CreateBy = c.CreateBy,
                CreateDate = c.CreateDate,
                Description = c.Description
            }).AsEnumerable().Select(x => new CommendList
            {
                ID          = x.ID,
                CreateBy    = x.CreateBy,
                CreateDate  = x.CreateDate,
                Description = x.Description
            }).ToList();

            foreach (var e in list)
            {
                var sff = context.Staffs.SingleOrDefault(x => x.ID == e.CreateBy);
                e.CreateName = sff.Name;
            }

            issue.CommendList = list;


            ViewBag.CommendList = new SelectList(db.Commends, "ID", "Description");
            ViewBag.TgList      = db.TopicGroups.ToList();
            ViewBag.WhList      = db.Warehouses.ToList();
            ViewBag.StList      = db.Staffs.ToList();

            //because DB Topic has no name but has subject but Viewbag for dropdownlist must has name
            var listT = db.Topics.ToList();

            foreach (var i in listT)
            {
                i.Name = i.Subject;
            }
            ViewBag.TpList = listT;

            return(View(issue));
        }
示例#30
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                GetCardInfoRequest parm = new GetCardInfoRequest();
                using (StreamReader sr = new StreamReader(context.Request.InputStream))
                {
                    String data = sr.ReadToEnd();
                    parm = new JavaScriptSerializer().Deserialize <GetCardInfoRequest>(data);
                }

                GetCardInfoResponse ap = new GetCardInfoResponse();
                using (DLSMEntities db = new DLSMEntities())
                {
                    db.Database.Connection.Open();

                    using (var dbContextTransaction = db.Database.BeginTransaction())
                    {
                        try
                        {
                            var result = db.sp_ApiGetCardInfo(parm.WH_ID, parm.staffId, parm.cardEIN).ToList();

                            if (result.Count() > 0)
                            {
                                db.SaveChanges();
                                dbContextTransaction.Commit();
                                ap.addrNo = result[0].addrNo;

                                ap.ampDesc           = result[0].ampDesc;
                                ap.ampDescEng        = result[0].ampDescEng;
                                ap.birthDateStr      = result[0].birthDateStr;
                                ap.birthFlag         = result[0].birthFlag;
                                ap.distDesc          = result[0].distDesc;
                                ap.distDescEng       = result[0].distDescEng;
                                ap.docNo             = result[0].docNo;
                                ap.docType           = result[0].docType;
                                ap.reqMasRef         = result[0].reqMasRef;
                                ap.expDateStr        = result[0].expDateStr;
                                ap.fname             = result[0].fname;
                                ap.fnameEng          = result[0].fnameEng;
                                ap.issDateStr        = result[0].issDateStr;
                                ap.issOffLocCode     = result[0].issOffLocCode;
                                ap.lane              = result[0].lane;
                                ap.lname             = result[0].lname;
                                ap.lnameEng          = result[0].lnameEng;
                                ap.locFullDesc       = result[0].locFullDesc;
                                ap.natDesc           = result[0].natDesc;
                                ap.offLocDesc        = result[0].offLocDesc;
                                ap.offLocEngDesc     = result[0].offLocEngDesc;
                                ap.offRegDesc        = result[0].offRegDesc;
                                ap.offRegEngDesc     = result[0].offRegEngDesc;
                                ap.pcNo              = result[0].pcNo;
                                ap.pltCode           = result[0].pltCode;
                                ap.pltDesc           = result[0].pltDesc;
                                ap.pltEngDesc        = result[0].pltEngDesc;
                                ap.pltNo             = result[0].pltNo;
                                ap.pltPrnDesc        = result[0].pltPrnDesc;
                                ap.prevExpDateStr    = result[0].prevExpDateStr;
                                ap.prevIssDateStr    = result[0].prevIssDateStr;
                                ap.prevOffLocDesc    = result[0].prevOffLocDesc;
                                ap.prevOffRegDesc    = result[0].prevOffRegDesc;
                                ap.prevOffRegEngDesc = result[0].prevOffRegEngDesc;
                                ap.prevPltDesc       = result[0].prevPltDesc;
                                ap.prevPltNo         = result[0].prevPltNo;
                                ap.prvCode           = result[0].prvCode;
                                ap.prvDesc           = result[0].prvDesc;
                                ap.prvDescEng        = result[0].prvDescEng;
                                ap.rcpNo             = result[0].rcpNo;
                                ap.reqDateStr        = result[0].reqDateStr;
                                ap.reqNo             = result[0].reqNo;
                                ap.reqTrDesc         = result[0].reqTrDesc;
                                ap.sex                = result[0].sex;
                                ap.soi                = result[0].soi;
                                ap.street             = result[0].street;
                                ap.titleAbrev         = result[0].titleAbrev;
                                ap.titleDesc          = result[0].titleDesc;
                                ap.titleEngAbrev      = result[0].titleEngAbrev;
                                ap.villageNo          = result[0].villageNo;
                                ap.zipCode            = result[0].zipCode;
                                ap.alienFlag          = result[0].alienFlag;
                                ap.ccFlag             = result[0].ccFlag;
                                ap.DCICode            = result[0].DCICode;
                                ap.conditionDesc      = result[0].conditionDesc;
                                ap.organDonateFlag    = result[0].organDonateFlag;
                                ap.TRSFlag            = result[0].TRSFlag;
                                ap.firstIssueDateStr  = result[0].firstIssueDateStr;
                                ap.pltDescShort       = result[0].pltDescShort;
                                ap.pltNo1             = result[0].pltNo1;
                                ap.pltNo2             = result[0].pltNo2;
                                ap.prevPltDescShort   = result[0].prevPltDescShort;
                                ap.prevPltNo1         = result[0].prevPltNo1;
                                ap.prevPltNo2         = result[0].prevPltNo2;
                                ap.pltNoEng           = result[0].pltNoEng;
                                ap.workstationId      = result[0].workstationId;
                                ap.productType        = result[0].productType;
                                ap.CardEIN            = result[0].CardEIN;
                                ap.qrCode             = result[0].qrCode;
                                ap.cardStatus         = result[0].cardStatus; // 1: ดี , 2: เสีย, 3: ไม่พิมพ์
                                ap.startPrintDttmStr  = result[0].startPrintDttmStr;
                                ap.finishPrintDttmStr = result[0].finishPrintDttmStr;
                                ap.person_image       = result[0].PartData;

                                ap.message    = "OK";
                                ap.resultCode = "1";
                            }
                            else
                            {
                                dbContextTransaction.Rollback();
                                ap.resultCode = "0";
                                ap.message    = "not found";
                            }
                        }
                        catch (Exception ex)
                        {
                            dbContextTransaction.Rollback();
                            ap.resultCode = "0";
                            ap.message    = ex.InnerException == null ? (ex.Message == null ? "Error: GetCardInfo catch 2" : ex.Message) : ex.InnerException.Message + " StackTrace:" + ex.StackTrace;
                        }
                    }
                }
                string json = new JavaScriptSerializer().Serialize(ap);

                context.Response.ContentType = "text/javascript";
                context.Response.Write(json);
            }
            catch (Exception ex)
            {
                GetCardInfoResponse ap = new GetCardInfoResponse();
                ap.resultCode = "0";
                ap.message    = ex.InnerException == null ? (ex.Message == null ? "Error: GetCardInfo catch 1" : ex.Message) : ex.InnerException.Message + " StackTrace:" + ex.StackTrace;


                string json = new JavaScriptSerializer().Serialize(ap);
                context.Response.ContentType = "text/javascript";
                context.Response.Write(json);
            }
        }