Exemplo n.º 1
0
 public ActionResult 工作日誌()
 {
     if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] != null)
     {
         MotaiDataEntities dbContext = new MotaiDataEntities();
         tEmployee         emp       = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
         var dlist    = dbContext.tDiaries.Where(c => c.dEmployeeId == emp.EmployeeId).ToList();
         var dlistnew = dlist.OrderByDescending(c => c.dDate).ToList();
         List <DiaryViewModel> DSaw = new List <DiaryViewModel>();
         foreach (var item in dlistnew)
         {
             DiaryViewModel show = new DiaryViewModel();
             show.eName            = item.tEmployee.eName;
             show.dDate            = item.dDate;
             show.dWeather         = item.dWeather;
             show.dDiaryNote       = item.dDiaryNote;
             show.DiaryId          = item.DiaryId;
             show.dWarehouseNameId = item.dWarehouseNameId;
             show.dWarehouseName   = dbContext.tWarehouseNames.Where(w => w.WarehouseNameId == item.dWarehouseNameId).FirstOrDefault().WarehouseName;
             DSaw.Add(show);
         }
         return(View(DSaw));
     }
     return(RedirectToAction("員工登入", "Employee"));
 }
        //Action=>取得會員個人照片
        public ActionResult GetImageByte(int id)
        {
            tEmployee empPicture = db.tEmployee.Find(id);

            byte[] img = empPicture.fEp_Picture;
            return(File(img, "image/jpeg"));
        }
Exemplo n.º 3
0
        public ActionResult AccountManager([Bind(Include = "fEp_ID,fEp_Code,fEp_Name,fEp_SSNumber,fEp_Addr,fEp_Tel,fEp_Phone,fId_ID,fEp_Seniority,fSe_ID,fEp_Nickname,fEp_Password,fEp_Email,fEp_Picture,fEp_Birth")] tEmployee tEmployee, HttpPostedFileBase EmployeeImage, string employeepassword)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tEmployee).State = EntityState.Modified;
                if (EmployeeImage != null && EmployeeImage.ContentLength > 0 && employeepassword != null)
                {
                    //將上傳的圖轉成二進位
                    var    imgSize = EmployeeImage.ContentLength;
                    byte[] imgByte = new byte[imgSize];
                    EmployeeImage.InputStream.Read(imgByte, 0, imgSize);
                    tEmployee.fEp_Password = employeepassword;
                    tEmployee.fEp_Picture  = imgByte;

                    db.Entry(tEmployee).State = EntityState.Modified;

                    db.SaveChanges();

                    return(RedirectToAction("Bulletin", "Home"));
                }
            }
            ViewBag.fId_ID = new SelectList(db.tIdentity, "fId_ID", "fId_Identity", tEmployee.fId_ID);
            ViewBag.fSe_ID = new SelectList(db.tSector, "fSe_ID", "fSe_Sector", tEmployee.fSe_ID);
            return(PartialView(tEmployee));
        }
Exemplo n.º 4
0
        public ActionResult Create(tEmployee employee)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    ObjectParameter param = new ObjectParameter("fEmpId", typeof(Int32));

                    var result = db.usp_PR_Employee_Insert(
                        param,
                        employee.fName,
                        employee.fPhone,
                        employee.fDepId);

                    //員工編號
                    var EmployeeId = param.Value;
                    return(RedirectToAction("Index", new { depId = employee.fDepId }));
                }
                catch
                {
                    throw;
                }
            }
            return(View());
        }
Exemplo n.º 5
0
        public ActionResult ImagePreview(int?id)
        {
            tEmployee tEmployee = db.tEmployee.Find(id);

            byte[] img = tEmployee.fEp_Picture;
            return(File(img, "image/jpeg"));
        }
Exemplo n.º 6
0
        public IHttpActionResult PuttEmployee(int id, tEmployee tEmployee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tEmployee.ID)
            {
                return(BadRequest());
            }

            db.Entry(tEmployee).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tEmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        //報名頁面
        public ActionResult Sign_up(int id)
        {
            string    Ep_Code = Request.Cookies["account"].Value;
            tEmployee Ep      = db.tEmployee.Where(a => a.fEp_Code == Ep_Code).Single();

            if (db.tRegistrationDetail.Where(a => a.fEp_ID == Ep.fEp_ID && a.fSt_ID != 5).ToList().Select(a => a.tTravelCase.tDayTravel.Last().fDT_Date.Year).Where(a => a == DateTime.Now.Year).Any())
            {
                return(RedirectToAction("CaseDetail", "TraveCase", new { area = "EmployeeTrave", id = id, had = true }));
            }

            tTravelCase TC = db.tTravelCase.Find(id);

            int grantyear = 4500;
            int gotday    = (((DateTime.Now) - (db.tEmployee.Where(a => a.fEp_ID == Ep.fEp_ID).Single().fEp_Seniority)).Days);
            int grant     = gotday > 365 ? grantyear : (gotday / 30 * (grantyear / 12));

            List <tRegistrationDetail> Case1 = db.tRegistrationDetail.Where(a => a.fTC_ID == id).ToList();
            int Sum = 0;

            Sum += Case1.Where(a => a.fSt_ID != 5).Count();
            foreach (int rdID in Case1.Where(a => a.fSt_ID != 5).Select(a => a.fRD_ID))
            {
                Sum += db.tFamily.Where(a => a.fRD_ID == rdID && a.fFa_Car == true).Count();
                Sum += db.tDependentsTravel.Where(a => a.fRD_ID == rdID && a.fDT_Car == true).Count();
            }

            ViewBag.SumNow     = Sum;
            ViewBag.RD_Grant   = grant;
            ViewBag.Ep_De      = db.tDependents.Where(a => a.fEp_ID == Ep.fEp_ID).ToList();
            ViewBag.Employee   = Ep;
            ViewBag.TravelCase = TC;


            return(View());
        }
Exemplo n.º 8
0
        //進貨單
        public ActionResult 進貨單建立()
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();

            if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] != null)
            {
                StockCreateViewModel model  = new StockCreateViewModel();
                StockDetailViewModel detail = new StockDetailViewModel();
                tEmployee            emp    = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
                model.sEmployeeId = emp.EmployeeId;
                var productNames = productRespoitory.GetNameAll();
                List <SelectListItem> productlist = productRespoitory.GetPositionName(productNames);
                var warehouseNames = commodityRespoitory.GetWarehouseAll();
                List <SelectListItem> warehouselist = commodityRespoitory.GetSelectList(warehouseNames);
                detail.WareHouseNames = warehouselist;
                detail.ProductNames   = productlist;
                DateTime today = DateTime.Now.Date;
                var      count = dbContext.tStockLists.Where(s => s.sStockDate == today).ToList().Count;
                count++;
                model.sStockSerialValue = Convert.ToInt32(DateTime.Now.ToString("yyMMdd") + count.ToString("0000"));
                model.StockDetail       = detail;
                model.sStockDate        = DateTime.Now;
                return(View(model));
            }
            else
            {
                return(RedirectToAction("員工登入", "Employee"));
            }
        }
Exemplo n.º 9
0
        public ActionResult EmpForgotPassword(EmpChangePasswordViewModel e) //忘記密碼
        {
            if (!string.IsNullOrEmpty(e.oldAccount))
            {
                tEmployee cust = db.tEmployees.First(p => p.fUserName == e.oldAccount);
                if (e.OldPassword == "1234")
                {
                    PasswordHasher pw       = new PasswordHasher();
                    string         pwstring = e.NewPassword;
                    string         bepw     = pw.HashPassword(pwstring);
                    cust.fLoginPassword = bepw;
                    db.SaveChanges();

                    return(RedirectToAction("EmpLogin"));
                }
                else
                {
                    return(RedirectToAction("EmpForgotPassword"));
                }
            }
            else
            {
                return(RedirectToAction("EmpForgotPassword"));
            }
        }
Exemplo n.º 10
0
        public ActionResult Edit(tEmployee e, string PassWord)//錄取員工資訊
        {
            tEmployee employee = db.tEmployees.First(p => p.fEmployeeID == e.fEmployeeID);

            if (employee == null)
            {
                return(RedirectToAction("Employeeslist"));
            }
            PasswordHasher pw       = new PasswordHasher();
            string         pwstring = PassWord;
            string         bepw     = pw.HashPassword(pwstring);

            employee.fLoginPassword = bepw;
            employee.fName          = e.fName;
            employee.fUserName      = e.fUserName;
            employee.fBirthday      = e.fBirthday;
            employee.fEmail         = e.fEmail;
            employee.fPhone         = e.fPhone;
            employee.fAddress       = e.fAddress;
            employee.fDepartmentID  = e.fDepartmentID;
            employee.fJobTitleID    = e.fJobTitleID;
            employee.fHireDate      = e.fHireDate;
            employee.fUpdateDate    = DateTime.Now;
            db.SaveChanges();
            return(RedirectToAction("Employeeslist"));
        }
Exemplo n.º 11
0
        public JsonResult 員工登入(EmployeeLoginViewModel e登入資料)
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();
            tEmployee         d資料確認     = dbContext.tEmployees.Where(e => e.eAccount == e登入資料.eAccount && e.ePassword.Equals(e登入資料.ePassword)).FirstOrDefault();

            if (d資料確認 != null)
            {
                Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] = d資料確認;
                switch (d資料確認.eBranch)
                {
                case 1:
                    return(Json(new { result = true, msg = "登入成功", url = Url.Action("Boss首頁", "Boss") }));

                case 2:
                    return(Json(new { result = true, msg = "登入成功", url = Url.Action("Business首頁", "Business") }));

                case 3:
                    return(Json(new { result = true, msg = "登入成功", url = Url.Action("Accountant首頁", "Accountant") }));

                case 4:
                    return(Json(new { result = true, msg = "登入成功", url = Url.Action("People首頁", "People") }));

                case 5:
                    return(Json(new { result = true, msg = "登入成功", url = Url.Action("Commodity首頁", "Commodity") }));

                default:
                    return(Json(new { result = true, msg = "帳號或密碼有誤", url = Url.Action("員工首頁", "Employee") }));
                }
            }
            else
            {
                return(Json(new { result = false, msg = "帳號或密碼有誤" }));
            }
        }
Exemplo n.º 12
0
        public ActionResult 人員檢視()
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();

            if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] == null)
            {
                return(RedirectToAction("員工登入", "Employee"));
            }
            tEmployee empse   = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
            var       empall  = dbContext.tEmployees.OrderBy(c => c.eBranch).ToList();
            var       empall2 = empall.OrderBy(c => c.ePosition).ToList();
            var       empall3 = empall2.OrderBy(c => c.eBranch).ToList();
            List <EmployeeViewModels> employees = new List <EmployeeViewModels>();

            foreach (var item in empall3)
            {
                EmployeeViewModels employeeModel = new EmployeeViewModels();
                employeeModel.EmployeeId = item.EmployeeId;
                employeeModel.eAccount   = item.eAccount;
                employeeModel.eName      = item.eName;
                employeeModel.sPosition  = item.tPosition.pPosition;
                employeeModel.sBranch    = item.tBranch.bBranch;
                employees.Add(employeeModel);
            }
            return(View(employees));
        }
Exemplo n.º 13
0
 public JsonResult ChangePassword(int EmployeeId, string ePassword, string oldpass)
 {//要用到其他地方
     if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] != null)
     {
         tEmployee         emp       = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
         MotaiDataEntities dbContext = new MotaiDataEntities();
         tEmployee         changeemp = new tEmployee();
         changeemp            = emp;
         changeemp.EmployeeId = EmployeeId;
         dbContext.tEmployees.Add(changeemp);
         dbContext.SaveChanges();
         if (emp.ePassword == oldpass)
         {
             emp.ePassword = ePassword;
             Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] = emp;
             tEmployee changePwd = dbContext.tEmployees.Where(e => e.EmployeeId.Equals(emp.EmployeeId)).FirstOrDefault();
             changePwd.ePassword = ePassword;
             dbContext.SaveChanges();
             return(Json(new { result = true, msg = "更新成功" }));
         }
         else
         {
             return(Json(new { result = false, msg = "舊密碼錯誤" }));
         }
     }
     else
     {
         return(Json(new { result = false, msg = "請先登入" }));
     }
 }
 public ActionResult AddOrEdit(tEmployee emp)
 {
     try
     {
         if (emp.fImageUpload != null)
         {
             string filename  = Path.GetFileNameWithoutExtension(emp.fImageUpload.FileName);
             string extension = Path.GetExtension(emp.fImageUpload.FileName);
             filename       = filename + DateTime.Now.ToString("yymmssfff") + extension;
             emp.fImagePath = "~/AppFiles/images/" + filename;
             emp.fImageUpload.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/images/"), filename));
         }
         using (dbJQueryAjaxMVCEntities db = new dbJQueryAjaxMVCEntities())
         {
             if (emp.fEmpId == 0)
             {
                 db.tEmployees.Add(emp);
                 db.SaveChanges();
             }
             else
             {
                 db.Entry(emp).State = EntityState.Modified;
                 db.SaveChanges();
             }
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllEmployee()), message = "成功新增!!" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(new { success = false, message = e.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 15
0
 public JsonResult 實體店新增訂單(EmployeeOrderViewModel empOrder)
 {
     if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] != null)
     {
         tEmployee emp = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
         if (Session[CSession關鍵字.SK_ORDERDETAIL] == null)
         {
             return(Json(new { result = false, msg = "訂單尚未完成!", url = Url.Action("實體店新增訂單", "Order") }));
         }
         else
         {
             List <EmployeeOrderDetailViewModel> orders = Session[CSession關鍵字.SK_ORDERDETAIL] as List <EmployeeOrderDetailViewModel>;
             MotaiDataEntities dbContext = new MotaiDataEntities();
             tCustomer         customer  = dbContext.tCustomers.Where(c => c.cCellPhone == empOrder.cCellphone).FirstOrDefault();
             tOrder            list      = new tOrder();
             list.oEmployeeId = emp.EmployeeId;
             list.oCustomerId = customer.CustomerId;
             if (empOrder.oAddress == null)
             {
                 list.oAddress = customer.cAddress;
             }
             else
             {
                 list.oAddress = empOrder.oAddress;
             }
             list.oDate          = empOrder.oDate;
             list.cNote          = empOrder.cNote;
             list.oWarehouseName = empOrder.oWarehouseName;
             dbContext.tOrders.Add(list);
             dbContext.SaveChanges();
             int orderId       = dbContext.tOrders.OrderByDescending(i => i.OrderId).First().OrderId;
             int originalPrice = 0;
             foreach (var items in orders)
             {
                 tOrderDetail detail = new tOrderDetail();
                 detail.oOrderId    = orderId;
                 detail.oProductId  = items.oProductId;
                 detail.oProductQty = items.oProductQty;
                 detail.oNote       = items.oNote;
                 dbContext.tOrderDetails.Add(detail);
                 tProduct product = dbContext.tProducts.Where(p => p.ProductId.Equals(items.oProductId)).FirstOrDefault();
                 originalPrice += items.oProductQty * Convert.ToInt32(product.pPrice);
             }
             tOrder order       = dbContext.tOrders.Where(o => o.OrderId == orderId).FirstOrDefault();
             int    promotionId = orderRespoitory.SelectPromotionId(originalPrice, empOrder.oDate);
             if (promotionId != 0)
             {
                 order.oPromotionId = promotionId;
             }
             dbContext.SaveChanges();
             Session[CSession關鍵字.SK_ORDERDETAIL] = null;
             return(Json(new { result = true, msg = "新增成功", url = Url.Action("realCheckView", "Order"), OrderId = orderId }));
         }
     }
     else
     {
         return(Json(new { result = false, msg = "尚未登入!", url = Url.Action("員工登入", "Employee") }));
     }
 }
Exemplo n.º 16
0
 public ActionResult Edit(tEmployee employee)
 {
     if (ModelState.IsValid)
     {
         db.UpdateEmployee(employee);
         return(RedirectToAction("Index", new { id = employee.fDepId }));
     }
     return(View());
 }
Exemplo n.º 17
0
 public ActionResult Create(tEmployee employee)
 {
     if (ModelState.IsValid)
     {
         var result = db.AddEmployee(employee);
         return(RedirectToAction("Index", new { id = employee.fDepId }));
     }
     return(View());
 }
Exemplo n.º 18
0
        public VMEmployee convert(tEmployee emp)
        {
            this.id         = emp.fEmployeeId;
            this.department = emp.fDepartment;
            this.job        = emp.fTitle;
            this.name       = emp.fName;

            return(this);
        }
Exemplo n.º 19
0
 public ActionResult Create(tEmployee e) //建立員工帳號
 {
     e.fJobTitleID   = 0;
     e.fDepartmentID = 0;
     e.fUpdateDate   = DateTime.Now.ToLocalTime();
     db.tEmployees.Add(e);
     db.SaveChanges();
     return(RedirectToAction("thanks"));
 }
Exemplo n.º 20
0
 public JsonResult 進貨單建立(StockCreateViewModel stockList)
 {
     if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] != null)
     {
         tEmployee emp = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
         if (Session[CSession關鍵字.SK_STOCKDETAIL] == null)
         {
             return(Json(new { result = false, msg = "進貨單尚未完成!", url = "" }));
         }
         else
         {
             List <StockDetailViewModel> stocks    = Session[CSession關鍵字.SK_STOCKDETAIL] as List <StockDetailViewModel>;
             MotaiDataEntities           dbContext = new MotaiDataEntities();
             tStockList list = new tStockList();
             list.sEmployeeId       = emp.EmployeeId;
             list.sStockSerialValue = stockList.sStockSerialValue;
             list.sVendor           = stockList.sVendor;
             list.sVendorTel        = stockList.sVendorTel;
             list.sStockDate        = stockList.sStockDate;
             list.sStockNote        = stockList.sStockNote;
             dbContext.tStockLists.Add(list);
             dbContext.SaveChanges();
             foreach (var items in stocks)
             {
                 tStockDetail detail = new tStockDetail();
                 detail.sStockId         = dbContext.tStockLists.OrderByDescending(i => i.StockId).First().StockId;
                 detail.sProductId       = items.sProductId;
                 detail.sCost            = items.sCost;
                 detail.sQuantity        = items.sQuantity;
                 detail.sWarehouseNameId = items.sWarehouseNameId;
                 detail.sNote            = items.sNote;
                 dbContext.tStockDetails.Add(detail);
                 //倉儲變動
                 tWarehouse Warehouse = dbContext.tWarehouses.Where(w => w.WarehouseNameId.Equals(items.sWarehouseNameId) && w.wProductId.Equals(items.sProductId)).FirstOrDefault();
                 if (Warehouse != null)
                 {
                     Warehouse.wPQty += items.sQuantity;
                 }
                 else
                 {
                     tWarehouse warehouse = new tWarehouse();
                     warehouse.WarehouseNameId = items.sWarehouseNameId;
                     warehouse.wProductId      = items.sProductId;
                     warehouse.wPQty           = items.sQuantity;
                     dbContext.tWarehouses.Add(warehouse);
                 }
             }
             dbContext.SaveChanges();
             Session[CSession關鍵字.SK_STOCKDETAIL] = null;
             return(Json(new { result = true, msg = "新增成功", url = Url.Action("進貨單建立", "Commodity") }));
         }
     }
     else
     {
         return(Json(new { result = false, msg = "尚未登入!", url = Url.Action("員工登入", "Employee") }));
     }
 }
Exemplo n.º 21
0
 //客戶看訂單
 public ActionResult 過往訂單()
 {
     if (Session[CSession關鍵字.SK_LOGINED_CUSTOMER] != null)
     {
         tCustomer                     cust      = Session[CSession關鍵字.SK_LOGINED_CUSTOMER] as tCustomer;
         MotaiDataEntities             db        = new MotaiDataEntities();
         List <tOrder>                 orders    = db.tOrders.Where(o => o.oCustomerId == cust.CustomerId).ToList();
         List <CustomerOrderViewModel> OrderList = new List <CustomerOrderViewModel>();
         foreach (var items in orders)
         {
             CustomerOrderViewModel order = new CustomerOrderViewModel();
             order.oDate         = items.oDate;
             order.WarehouseName = db.tWarehouseNames.Where(w => w.WarehouseNameId.Equals(items.oWarehouseName)).FirstOrDefault().WarehouseName;
             tEmployee employee = db.tEmployees.Where(e => e.EmployeeId == items.oEmployeeId).FirstOrDefault();
             if (employee != null)
             {
                 order.EmployeeName = employee.eName;
             }
             order.cNote = items.cNote;
             List <tOrderDetail> orderdetails = db.tOrderDetails.Where(od => od.oOrderId == items.OrderId).ToList();
             List <CustomerOrderDetailViewModel> OrderDetailList = new List <CustomerOrderDetailViewModel>();
             int originPrice = 0;
             foreach (var itemDetail in orderdetails)
             {
                 CustomerOrderDetailViewModel orderdetail = new CustomerOrderDetailViewModel();
                 tProduct product = db.tProducts.Where(p => p.ProductId == itemDetail.oProductId).FirstOrDefault();
                 orderdetail.ProductNum   = product.pNumber;
                 orderdetail.ProductName  = product.pName;
                 orderdetail.ProductPrice = product.pPrice;
                 orderdetail.oProductQty  = itemDetail.oProductQty;
                 orderdetail.oNote        = itemDetail.oNote;
                 OrderDetailList.Add(orderdetail);
                 originPrice += Convert.ToInt32(product.pPrice) * itemDetail.oProductQty;
             }
             if (items.oPromotionId != null)
             {
                 tPromotion promotion = db.tPromotions.Where(p => p.PromotionId == items.oPromotionId).FirstOrDefault();
                 order.TotalAmount = originPrice - Convert.ToInt32(promotion.pDiscount);
             }
             else
             {
                 order.TotalAmount = originPrice;
             }
             List <tOrderPay> paylists = db.tOrderPays.Where(op => op.oOrderId == items.OrderId).ToList();
             foreach (var itemPay in paylists)
             {
                 order.AlreadyPay += Convert.ToInt32(itemPay.oPayment);
             }
             order.Unpaid = order.TotalAmount - order.AlreadyPay;
             order.CustomerOrderDetails = OrderDetailList;
             OrderList.Add(order);
         }
         return(View(OrderList));
     }
     return(RedirectToAction("首頁"));
 }
Exemplo n.º 22
0
        public VMEmployee convert(tEmployee emp)
        {
            VMEmployee vMEmployee = new VMEmployee();

            vMEmployee.id         = emp.fEmployeeId;
            vMEmployee.department = emp.fDepartment;
            vMEmployee.job        = emp.fTitle;
            vMEmployee.name       = emp.fName;

            return(vMEmployee);
        }
Exemplo n.º 23
0
        public ActionResult Delete(int?id) //刪除員工資訊並不錄取
        {
            tEmployee employee = db.tEmployees.First(p => p.fEmployeeID == id);

            if (employee != null)
            {
                db.tEmployees.Remove(employee);
                db.SaveChanges();
                return(RedirectToAction("Employeeslist"));
            }
            return(View("Employeeslist"));
        }
Exemplo n.º 24
0
        public VMEmployee convert(tEmployee emp)
        {
            VMEmployee vmemp = new VMEmployee();

            vmemp.id         = emp.fEmployeeId;
            vmemp.department = emp.fDepartment;
            vmemp.title      = emp.fTitle;
            vmemp.name       = emp.fName;
            vmemp.auth       = emp.fAuth;

            return(vmemp);
        }
Exemplo n.º 25
0
        public IHttpActionResult PosttEmployee(tEmployee tEmployee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tEmployees.Add(tEmployee);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tEmployee.ID }, tEmployee));
        }
Exemplo n.º 26
0
        public ActionResult 訂單查詢()
        {
            if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] == null)
            {
                return(RedirectToAction("員工登入", "Employee"));
            }
            tEmployee             employee   = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
            List <OrderViewModel> CheckOrder = new List <OrderViewModel>();

            CheckOrder = orderRespoitory.GetOrderAllByEmp(employee.EmployeeId);
            return(View(CheckOrder));
        }
Exemplo n.º 27
0
        public ActionResult Create(string fName, string fPhone, int fSalary, string 帳號, string 密碼)
        {
            tEmployee emp = new tEmployee();

            emp.fName   = fName;
            emp.fPhone  = fPhone;
            emp.fSalary = fSalary;
            emp.帳號      = 帳號;
            emp.密碼      = 密碼;
            db.tEmployee.Add(emp);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult AddOrEdit(int id = 0)
        {
            tEmployee t = new tEmployee();

            if (id != 0)
            {
                using (dbJQueryAjaxMVCEntities db = new dbJQueryAjaxMVCEntities())
                {
                    t = db.tEmployees.Where(a => a.fEmpId == id).FirstOrDefault <tEmployee>();
                }
            }
            return(View(t));
        }
Exemplo n.º 29
0
 public ActionResult 修改日誌(int id)
 {
     if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] != null)
     {
         tEmployee         emp   = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
         MotaiDataEntities db    = new MotaiDataEntities();
         tDiary            diary = db.tDiaries.Where(d => d.dEmployeeId.Equals(emp.EmployeeId)).FirstOrDefault();
         DiaryViewModel    Diary = new DiaryViewModel();
         //Diary.Diary = diary;
         return(View(Diary));
     }
     return(RedirectToAction("員工登入"));
 }
Exemplo n.º 30
0
        public ActionResult 新增日誌()
        {
            tEmployee emp = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;

            ViewBag.name  = emp.eName;
            ViewBag.empId = emp.EmployeeId;
            DiaryViewModel        newDiary   = new DiaryViewModel();
            var                   warehouses = commodityRespoitory.GetWarehouseAll();
            List <SelectListItem> WareList   = commodityRespoitory.GetSelectList(warehouses);

            newDiary.warehouses = WareList;
            newDiary.dDate      = DateTime.Now;
            return(View(newDiary));
        }