private void clsAltoButton2_Click(object sender, EventArgs e) { dbContext = new BusinessDataBaseEntities(); FileStream fs = System.IO.File.OpenRead(label6.Text); byte[] imageb = new byte[fs.Length]; fs.Read(imageb, 0, imageb.Length); try { var q = new CompanyVehicle { LicenseNumber = textBox1.Text, VehicleYear = int.Parse(textBox2.Text), PurchaseDate = dateTimePicker1.Value, brand = textBox3.Text, serial = textBox4.Text, MaxPassenger = textBox5.Text, officeID = int.Parse(comboBox1.Text), VehiclePhoto = imageb }; dbContext.CompanyVehicles.Add(q); dbContext.SaveChanges(); MessageBox.Show("Succeed"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ActionResult Test() { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { //var q = (from p in db.CommentChilds // join l in db.CommentReplies on p.CommentMainID equals l.CommentMainID // where p.ChildNum != l.ChildNum && p.EmployeeID == EmployeeDetail.EmployeeID // select new // { // p.CommentMainID, // }).Distinct().ToList(); var q = db.CommentChilds .Where(x => x.EmployeeID == EmployeeDetail.EmployeeID) .Where(x => !db.CommentReplies.Any(y => y.CommentChild.ChildNum == x.ChildNum)).Select(z => z.CommentMainID).Distinct().ToList(); if (q.Count() != 0) { var k = q.Count(); return(Json(new { len = k }, JsonRequestBehavior.AllowGet)); } else { return(Json(null, JsonRequestBehavior.AllowGet)); } }; }
public ActionResult AddOrEdit2(CompanyVehicleViewModel b) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { string SourceFilename = Path.GetFileName(b.PhotoCar.FileName); string appPath = Request.PhysicalApplicationPath; string saveDir = "\\CarUpload\\"; string savePath = appPath + saveDir + SourceFilename; b.PhotoCar.SaveAs(savePath); db.CompanyVehicles.Add(new CompanyVehicle() { LicenseNumber = b.LicenseNumber, VehicleYear = b.VehicleYear, PurchaseDate = b.PurchaseDate, brand = b.brand, serial = b.serial, MaxPassenger = b.MaxPassenger, officeID = b.officeID, VehiclePhoto2 = SourceFilename }); db.SaveChanges(); TempData["message"] = $"公務車資料新增完成"; return(RedirectToAction("AddOrEdit2", "CompanyVehicles")); } }
public ActionResult AddOrEditCC(CommentContent c) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { if (c.CommentContentID == 0) { db.CommentContents.Add(new CommentContent() { CommentOptionID = c.CommentOptionID, CommentContent1 = c.CommentContent1, CommentContentID = c.CommentContentID, }); db.SaveChanges(); return(Json(new { success = true, message = "調查主題新增成功" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(c).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "調查主題修改成功" }, JsonRequestBehavior.AllowGet)); } } }
private void SonForm_Load(object sender, EventArgs e) { BusinessDataBaseEntities dbContext; dbContext = new BusinessDataBaseEntities(); var q = from em in dbContext.Employees where em.employeeID == ClassEmployee.LoginEmployeeID select new { em.EmployeeName, em.Gender, em.Photo }; foreach (var n in q) { name = n.EmployeeName; gender = n.Gender; photo = n.Photo; } label3.Text = name; if (gender == "M") { label4.Text = "先 生"; } else { label4.Text = "小 姐"; } pictureBox2.ImageLocation = photo; }
public ActionResult AddOrEdit(CommentQuestion c) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { if (c.CommentQuestionID == 0) { int EmpID = EmployeeDetail.EmployeeID; //int ccID = 102; //ccID = Convert.ToInt32(formCollection["CommentContent"]); db.CommentQuestions.Add(new CommentQuestion() { Question = c.Question, //CommentQuestionID = c.CommentQuestionID, CommentContentID = c.CommentContentID, }); db.SaveChanges(); return(Json(new { success = true, message = "成功新建調查項目" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(c).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "成功修改調查項目" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult Reply(CommentChild c) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { //var data = from cc in db.CommentChilds // join cm in db.CommentMains // on cc.CommentMainID equals cm.CommentMainID // select new // { // cm.CommentMainID, // postperson = cm.EmployeeID, // cm.CommentName, // replyperson = cc.EmployeeID, // }; int empid = EmployeeDetail.EmployeeID; db.Entry(c).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "已送出回覆" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddOrEdit(CommentMain c, FormCollection formCollection) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { if (c.CommentMainID == 0) { int EmpID = EmployeeDetail.EmployeeID; int ccID = 102; ccID = Convert.ToInt32(formCollection["CommentContent"]); db.CommentMains.Add(new CommentMain() { CommentName = c.CommentName, SendTime = DateTime.Now, EmployeeID = EmpID, CommentContentID = ccID, CommentMainID = c.CommentMainID, }); db.SaveChanges(); return(Json(new { success = true, message = "調查發布成功" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(c).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "調查修改成功" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult AddOrEdit(int id = 0) { var userid = User.Identity.GetUserId(); var account = db.AspNetUsers.Find(userid); var empquery = from em in db.Employees where em.Account == account.UserName select new { em.employeeID, em.GroupID, em.DepartmentID }; int EmpID = 0; foreach (var e in empquery) { EmpID = e.employeeID; } if (id == 0) { return(View(new BulletinBoard())); } else { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { return(View(db.BulletinBoards.Where(x => x.Num == id).FirstOrDefault <BulletinBoard>())); } } }
private void button1_Click(object sender, EventArgs e) { dbContext = new BusinessDataBaseEntities(); CBDepartment.ItemCheck += CBDepartment_ItemCheck; var q = from b in dbContext.BulletinBoards join d in dbContext.Departments on b.DepartmentID equals d.departmentID join g in dbContext.Groups on b.GroupID equals g.GroupID join em in dbContext.Employees on b.EmployeeID equals em.employeeID select new { 部門 = d.name, 組別 = g.GroupName, 姓名 = em.EmployeeName, 留言內容 = b.Content, 張貼時間 = b.PostTime }; dataGridView1.DataSource = q.OrderByDescending(o => o.張貼時間).ToList(); dgvFormat(dataGridView1); CBDepartment.SetItemChecked(0, true); CBDepartment.SetItemChecked(1, true); CBDepartment.SetItemChecked(2, true); CBDepartment.SetItemChecked(3, true); CBDepartment.SetItemChecked(4, true); CBGroup.SetItemChecked(0, true); CBGroup.SetItemChecked(1, true); //this.dataGridView1.Update(); //this.dataGridView1.Refresh(); }
public ActionResult AddOrEdit(MeetingRoomHistory b) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { if (b.MeetingRoomID == 0) { } else { db.Entry(b).State = EntityState.Modified; db.SaveChanges(); } return(Json(new { success = true, message = "修改成功" }, JsonRequestBehavior.AllowGet)); //var saveCars = new BusinessSystemMVC_Admin_page_.Models.CompanyVehicleHistory //{ // VehicleHistoryID = b.VehicleHistoryID, // StartDateTime = b.StartDateTime, // EndDateTime = b.EndDateTime, // employeeID = b.employeeID, // purpose = b.purpose //}; //return Json(new { success = true, message = "修改成功" }, JsonRequestBehavior.AllowGet); } }
private IEnumerable <CommentQuestion> GetQuestions(int commentContentID) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { var query = db.CommentQuestions.Where(x => x.CommentContentID == commentContentID).OrderBy(x => x.CommentQuestionID); return(query.ToList()); } }
private IEnumerable <Department> GetDepartments() { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { var query = db.Departments.OrderBy(x => x.departmentID); return(query.ToList()); } }
private IEnumerable <CommentOption> GetOptions() { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { var query = db.CommentOptions.OrderBy(x => x.CommentOptionID); return(query.ToList()); } }
public ActionResult Delete(string id) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { MeetingRoom b = db.MeetingRooms.Where(x => x.meetingID == id).FirstOrDefault <MeetingRoom>(); db.MeetingRooms.Remove(b); db.SaveChanges(); return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { BulletinBoard b = db.BulletinBoards.Where(x => x.Num == id).FirstOrDefault <BulletinBoard>(); db.BulletinBoards.Remove(b); db.SaveChanges(); return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { CommentQuestion cq = db.CommentQuestions.Find(id); db.CommentQuestions.Remove(cq); db.SaveChanges(); return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteMessage(int id) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { var message = db.Messages.Where(m => m.MessageID == id && m.Status.Equals("true")).FirstOrDefault(); message.Status = "false"; db.SaveChanges(); return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { var recipient = db.Recipients.Where(r => r.RecipientID == id && r.Status.Equals("true")).FirstOrDefault(); recipient.Status = "false"; db.SaveChanges(); return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(string id) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { CompanyVehicle b = db.CompanyVehicles.Where(x => x.LicenseNumber == id).FirstOrDefault <CompanyVehicle>(); db.CompanyVehicles.Remove(b); db.SaveChanges(); return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { ReportTimeSystem r = db.ReportTimeSystems.Where(x => x.ReportID == id).FirstOrDefault <ReportTimeSystem>(); db.ReportTimeSystems.Remove(r); db.SaveChanges(); return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { CommentMain c = db.CommentMains.Where(x => x.CommentMainID == id).FirstOrDefault <CommentMain>(); db.CommentMains.Remove(c); db.SaveChanges(); return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { EventCalendar ca = db.EventCalendars.Where(x => x.CalendarID == id).FirstOrDefault <EventCalendar>(); db.EventCalendars.Remove(ca); db.SaveChanges(); return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddOrEdit(BulletinBoard b) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { if (b.Num == 0) { //db.BulletinBoards.Add(b); var userid = User.Identity.GetUserId(); var account = db.AspNetUsers.Find(userid); var empquery = from em in db.Employees where em.Account == account.UserName select new { em.employeeID, em.GroupID, em.DepartmentID }; int EmpID = 0; int?DID = 0; int?GID = 0; foreach (var e in empquery) { EmpID = e.employeeID; DID = e.DepartmentID; GID = e.GroupID; } db.BulletinBoards.Add(new BulletinBoard() { Content = b.Content, PostTime = DateTime.Now, DepartmentID = DID, GroupID = GID, EmployeeID = EmpID }); db.SaveChanges(); return(Json(new { success = true, message = "發布成功" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(b).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "修改成功" }, JsonRequestBehavior.AllowGet)); } } }
private void CreateEmployeeForm_Load(object sender, EventArgs e) { dbcontext = new BusinessDataBaseEntities(); //預設Office combobox內容 this.cmbOfficeID.DataSource = dbcontext.Offices.OrderBy(p => p.officeID).Select(p => p.office_name).Distinct().ToList(); this.cmbOfficeID.SelectedIndex = 1; // index 0 為Branch office ID應輸入 2,index 1 為Head office ID應輸入 1 //預設Department combobox內容 // if index==0 , 值為總經理,departmentID應輸入 index+1 累推 this.cmbDepartmentID.DataSource = dbcontext.Departments.OrderBy(p => p.departmentID).Select(p => p.name).ToList(); //預設Employed combobox內容 this.cmbEmployed.SelectedIndex = 1; // index 1 為"在職" 應輸入 1,index 0 為"離職" 應輸入 0 //預設Position ID內容 // if index==0 , 值為General manager,positionID應輸入 index+1 累推 this.cmbPositionID.DataSource = dbcontext.Positions.OrderBy(p => p.positionID).Select(p => p.position1).ToList(); }
public ActionResult AddOrEdit(string id) { if (id == null) { return(View(new MeetingRoom())); } else { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { return(View(db.MeetingRooms.Where(x => x.meetingID == id).FirstOrDefault <MeetingRoom>())); } } }
public ActionResult Reply(int id) { if (id == 0) { return(View(new CommentChild())); } else { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { return(View(db.CommentMains.Where(x => x.CommentMainID == id).FirstOrDefault())); } } }
public ActionResult AddOrEdit(string id) { if (id == null) { return(View(new CompanyVehicle())); } else { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { return(View(db.CompanyVehicles.Where(x => x.LicenseNumber == id).FirstOrDefault <CompanyVehicle>())); } } }
private void clsAltoButton1_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { BusinessDataBaseEntities dbContext; dbContext = new BusinessDataBaseEntities(); byte[] bytesPassword = Encoding.Unicode.GetBytes(this.txtLoginPassword.Text); SHA256Managed Algorithm = new SHA256Managed(); byte[] validPassword = Algorithm.ComputeHash(bytesPassword); var q = from em in dbContext.Employees join a in dbContext.Accounts on em.Account equals a.account1 where em.Account == this.txtLoginAccount.Text && a.password == validPassword select new { a.account1, a.password, em.employeeID, em.EmployeeName }; foreach (var v in q) { EmpID = v.employeeID; EmpName = v.EmployeeName; } if (q.Any()) { //readname.EmpAcount = this.txtLoginAccount.Text;//擷取登入者姓名 (Kai) MessageBox.Show($"歡迎回來, {EmpName}!", "登入成功", MessageBoxButtons.OK); //MessageBox.Show(readname.EmpAcount);//測試 //MainForm main = new MainForm(EmpID); //main.Show(); ClassEmployee.LoginEmployeeID = EmpID; this.Close(); } else { MessageBox.Show($"請重新登入", "登入失敗", MessageBoxButtons.OK); this.txtLoginPassword.Text = ""; this.txtLoginPassword.Focus(); ClassEmployee.LoginEmployeeID = 0; } } finally { this.Cursor = Cursors.Default; } }
public ActionResult AddOrEdit(int id = 0) { if (id == 0) { return(View(new MeetingRoomHistory())); } else { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { return(View(db.MeetingRoomHistories.Where(x => x.MeetingRoomID == id).FirstOrDefault <MeetingRoomHistory>())); } } }