public int InsertmApprovalLevel(mApprovalLevel approval, string[] conn) { BISPL_CRMDBEntities ce = new BISPL_CRMDBEntities(svr.GetEntityConnection(conn)); ce.mApprovalLevels.AddObject(approval); ce.SaveChanges(); return(Convert.ToInt32(approval.ID)); // return 1; }
public int updatemApprovalLevel(mApprovalLevel updateApproval, string[] conn) { BISPL_CRMDBEntities ce = new BISPL_CRMDBEntities(svr.GetEntityConnection(conn)); ce.mApprovalLevels.Attach(updateApproval); ce.ObjectStateManager.ChangeObjectState(updateApproval, EntityState.Modified); ce.SaveChanges(); return(1); }
/// <summary> /// GetApprovalRecordByID is providing List of Approval By ID for Edit mode /// </summary> /// <returns></returns> /// public mApprovalLevel GetApprovalRecordByID(int approvalId, string[] conn) { BISPL_CRMDBEntities ce = new BISPL_CRMDBEntities(svr.GetEntityConnection(conn)); mApprovalLevel ApprovalID = new mApprovalLevel(); ApprovalID = (from p in ce.mApprovalLevels where p.ID == approvalId select p).FirstOrDefault(); ce.Detach(ApprovalID); return(ApprovalID); }
protected void gvUserCreation_OnRebind(object sender, EventArgs e) { iApprovalLevelMasterClient ApprovalClient = new iApprovalLevelMasterClient(); CustomProfile profile = CustomProfile.GetProfile(); try { string insertgata = Session["InsertData"].ToString(); if (hdnStatus.Value == "Edit" && Session["InsertData"].ToString() == "") { //List<vGWCGetApprovalDetailsForEdit> getlst = new List<vGWCGetApprovalDetailsForEdit>(); //DataSet ds = new DataSet(); gvUserCreation.DataSource = ApprovalClient.GWCGetApprovalDetailsForEdit(Convert.ToInt64(hdnApprovalID.Value), profile.DBConnection._constr); //getlst = ApprovalClient.GWCGetApprovalDetailsForEdit(Convert.ToInt64(hdnApprovalID.Value), profile.DBConnection._constr).ToList(); //gvUserCreation.DataSource = getlst; gvUserCreation.DataBind(); // getlst = ApprovalClient.GWCGetUserForApprovalMaster(Convert.ToInt64(hdnSelectedLevel.Value), stringss[i], profile.DBConnection._constr).ToList(); GetApproverList(); } else if (hdnStatus.Value == "AddNew" && Hdn1.Value == "1" && Session["InsertData"].ToString() == "") { GetApproverList(); } else if (Session["InsertData"].ToString() == "Insert") { /*Add By Suresh*/ int AvailableApprovalLevel = ApprovalClient.GetApprovalRecordByApvrlLevelID(Convert.ToInt16(hdnSelectedLevel.Value), Convert.ToInt64(hdnSelectedDepartment.Value), profile.DBConnection._constr); if (AvailableApprovalLevel > 0) { // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "showAlert('Approval For This Level Are Already Available','Error','#')", true); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Approval For This Level Are Already Available')", true); } else { mApprovalLevel ObjApproval = new mApprovalLevel(); ObjApproval.ObjectName = "MaterialRequest"; ObjApproval.ApprovalLevel = Convert.ToByte(hdnSelectedLevel.Value); ObjApproval.NoOfApprovers = Convert.ToByte(txtnoapprovar.Text); ObjApproval.Active = "Y"; ObjApproval.TerritoryID = Convert.ToInt64(hdnSelectedDepartment.Value); ObjApproval.MinApprovalReq = 0; ObjApproval.MinApprovalReq = 0; ObjApproval.MaxAmount = 0; ObjApproval.IsLowerLevelApprovalReq = true; if (hdnSelectedDepartment.Value != "" || hdnSelectedDepartment.Value != "0") { ObjApproval.OrderCancelInDays = ApprovalClient.GetCancelDays(Convert.ToInt64(hdnSelectedDepartment.Value), profile.DBConnection._constr); } int result = 0; //if (hdnStatus.Value != "Edit") //{ ObjApproval.CreatedBy = profile.Personal.UserID.ToString(); ObjApproval.CreationDate = DateTime.Now; result = ApprovalClient.InsertmApprovalLevel(ObjApproval, profile.DBConnection._constr); // ObjApprovalDetail.ApprovalLevelID = result; // ApprovalClient.UpdateApprovallevelID(result, profile.DBConnection._constr); if (result != 0) { // WebMsgBox.MsgBox.Show("Record saved successfully"); } //} //else if (hdnStatus.Value == "Edit") //{ // ObjApproval.LastModifiedBy = profile.Personal.UserID.ToString(); // ObjApproval.LastModifiedDate = DateTime.Now; // result= Convert.ToInt32(hdnApprovalID.Value); //} /*Add By Suresh*/ mApprovalLevelDetail ObjApprovalDetail = new mApprovalLevelDetail(); string[] stringss = new string[] { }; hdnUserIDs.Value = Session["Userlist"].ToString(); stringss = hdnUserIDs.Value.Split(','); ObjApprovalDetail.ApprovalLevelID = result; //ObjApprovalDetail.ApprovalLevelID = 0; ObjApprovalDetail.Active = "Y"; ObjApprovalDetail.CreatedBy = profile.Personal.UserID.ToString(); ObjApprovalDetail.CreationDate = DateTime.Now; ObjApprovalDetail.CompanyID = Convert.ToInt64(hdnSelectedCompany.Value); ObjApprovalDetail.DepartmentID = Convert.ToInt64(hdnSelectedDepartment.Value); if (chkand.Checked == true) { ObjApprovalDetail.ApproverLogic = "AND"; } else { ObjApprovalDetail.ApproverLogic = "OR"; } for (int i = 0; i < stringss.Length; i++) { ObjApprovalDetail.UserID = Convert.ToInt64(stringss[i].ToString()); ApprovalClient.InsertGWCApprovalDetails(ObjApprovalDetail, profile.DBConnection._constr); } } GetApproverList(); Session["InsertData"] = ""; } } catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, "Approval Level Master", "gvUserCreation_OnRebind"); } finally { ApprovalClient.Close(); } }