public ActionResult SaveWRAdmin() { string strRet; uls_dbDataContext db = new uls_dbDataContext(); string strWRComment = Request.Form["txtWarnComments"]; string strOperation = Request.Form["hdnWROper"]; string strType = Request.Form["hdnWRType"]; string strDate = Request.Form["dtWarning"]; string strEmpID = Request.Form["hdnWREmpID"]; try { empWarnRecognition eWR; if (strOperation == "Add") { eWR = new empWarnRecognition(); eWR.empQualWarnRecogDate = Convert.ToDateTime(strDate); eWR.comment = strWRComment; eWR.employeeID = Convert.ToInt32(strEmpID); eWR.empWarnRecogFlg = Convert.ToChar(strType); db.empWarnRecognitions.InsertOnSubmit(eWR); } else { string strId = Request.Form["hdnEmailAdminID"]; eWR = db.empWarnRecognitions.Single(w => w.employeeID == Convert.ToInt32(strEmpID) && w.empQualWarnRecogDate == Convert.ToDateTime(strDate) && w.empWarnRecogFlg == Convert.ToChar(strType)); eWR.comment = strWRComment; } db.SubmitChanges(); strRet = "Success"; } catch (Exception ex) { string msg = ex.Message; strRet = msg; } finally { db.Dispose(); } return(Content(strRet)); }
public ActionResult DeleteWR(string id, string type, string date) { uls_dbDataContext db = new uls_dbDataContext(); string strRet; try { empWarnRecognition eWR = db.empWarnRecognitions.Single(w => w.employeeID == Convert.ToInt32(id) && w.empQualWarnRecogDate == Convert.ToDateTime(date) && w.empWarnRecogFlg == Convert.ToChar(type)); db.empWarnRecognitions.DeleteOnSubmit(eWR); db.SubmitChanges(); strRet = "Success"; } catch (Exception ex) { string strEX = ex.Message; strRet = "Failure"; } return(Content(strRet)); }