public static string SaveAccessDelegation(object objReq) { string result = ""; iUserCreationClient userClient = new iUserCreationClient(); try { string hiddneedit = ""; CustomProfile profile = CustomProfile.GetProfile(); Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary = (Dictionary <string, object>)objReq; long department = long.Parse(dictionary["department"].ToString()); long Delegateto = long.Parse(dictionary["Delegateto"].ToString()); string Remark = dictionary["Remark"].ToString(); string hndstate = dictionary["hndstate"].ToString(); long UserId = long.Parse(dictionary["UserId"].ToString()); DateTime FromDate = Convert.ToDateTime(dictionary["FromDate"].ToString()); DateTime ToDate = Convert.ToDateTime(dictionary["ToDate"].ToString()); // long newdelegate = long.Parse(dictionary["newDelegate"].ToString()); long DelegateId = 0; long delegatefrom = UserId; if (HttpContext.Current.Session["hdnedit"].ToString() != "" || HttpContext.Current.Session["hdnedit"].ToString() != null) { hndstate = HttpContext.Current.Session["hdnedit"].ToString(); } string hdndelegatestateedit = dictionary["hdndeligateeditstate"].ToString(); if (hndstate == "Edit") { string hdndeligateeditstate = hiddneedit.ToString(); hndstate = hdndeligateeditstate.ToString(); string delid = HttpContext.Current.Session["hdnnewDelegateid"].ToString(); DelegateId = long.Parse(delid.ToString()); HttpContext.Current.Session["hdnnewDelegateid"] = ""; HttpContext.Current.Session["hdnedit"] = ""; userClient.SaveEditUserDelegation(DelegateId, delegatefrom, FromDate, ToDate, Delegateto, Remark, hndstate, profile.Personal.UserID, DateTime.Now, department, profile.DBConnection._constr); } else { long valuecount = 0; valuecount = userClient.GetDuplicateDelegate(FromDate, ToDate, Delegateto, department, delegatefrom, profile.DBConnection._constr); if (valuecount == 0) { string hdndeligateeditstate = hiddneedit.ToString(); hndstate = hdndeligateeditstate.ToString(); hndstate = "Add"; //string delid = HttpContext.Current.Session["hdnnewDelegateid"].ToString(); // DelegateId = long.Parse(delid.ToString()); HttpContext.Current.Session["hdnnewDelegateid"] = ""; HttpContext.Current.Session["hdnedit"] = ""; userClient.SaveEditUserDelegation(DelegateId, delegatefrom, FromDate, ToDate, Delegateto, Remark, hndstate, profile.Personal.UserID, DateTime.Now, department, profile.DBConnection._constr); } else { result = "Exist"; } } } catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, "Access Delegation", "SaveAccessDelegation"); } finally { userClient.Close(); } return(result); }