예제 #1
0
 public ActionResult AddNew(Accountability data)
 {
     if (ModelState.IsValid)
     {
         data.DepartmentID = dbEmployee.GetDepartmentID(User.Identity.Name);
         dbContext.AddAccountability(data);
     }
     return RedirectToAction("Index");
 }
예제 #2
0
 public ActionResult Edit(int id, Accountability data)
 {
     if (ModelState.IsValid)
     {
         data.DepartmentID = dbEmployee.GetDepartmentID(User.Identity.Name);
         if (data.Status)
         {
             dbContext.DisableConfirmationCode(data.StudentNumber);
         }
         dbContext.EditAccountability(data, id);
     }
     return RedirectToAction("Index");
 }
예제 #3
0
 public void EditAccountability(Accountability data, int id)
 {
     ExecuteNonQuery(QueryBuilder.Update(_tableName, TargetFields, id, _pkField), SetParams(data));
 }
예제 #4
0
 public void AddAccountability(Accountability data)
 {
     ExecuteNonQuery(QueryBuilder.Insert(_tableName, TargetFields), SetParams(data));
 }
예제 #5
0
        private Dictionary<string, object> SetParams(Accountability data)
        {
            Dictionary<string, object> result = new Dictionary<string, object>();

            result.Add("@description", data.Description);
            result.Add("@studentNumber", data.StudentNumber);
            result.Add("@departmentID", data.DepartmentID);
            result.Add("@status", data.Status);
            return result;
        }
예제 #6
0
 public string MassUpload(HttpPostedFileBase excelFile, int departmentID)
 {
     try
     {
         foreach (KeyValuePair<string, string> value in ReadExcel(excelFile))
         {
             Accountability accountability = new Accountability
             {
                 DepartmentID = departmentID,
                 Description = value.Value,
                 StudentNumber = value.Key
             };
             AddAccountability(accountability);
         }
         return "Mass upload was successful!";
     }
     catch (Exception ex)
     {
         return ex.Message;
     }
 }