public int InsertmDepartment(mDepartment Department, string[] conn) { BISPL_CRMDBEntities ce = new BISPL_CRMDBEntities(svr.GetEntityConnection(conn));; ce.mDepartments.AddObject(Department); ce.SaveChanges(); return(1); }
/// <summary> /// GetDepartmentListByID is providing List of DepartmentList ByID /// </summary> /// <returns></returns> /// public mDepartment GetDepartmentListByID(int DepartmentId, string[] conn) { BISPL_CRMDBEntities ce = new BISPL_CRMDBEntities(svr.GetEntityConnection(conn));; mDepartment DepartmentID = new mDepartment(); DepartmentID = (from p in ce.mDepartments where p.ID == DepartmentId select p).FirstOrDefault(); ce.Detach(DepartmentID); return(DepartmentID); }
public int updatemDepartment(mDepartment updateDepartment, string[] conn) { BISPL_CRMDBEntities ce = new BISPL_CRMDBEntities(svr.GetEntityConnection(conn));; //string result = ""; ce.mDepartments.Attach(updateDepartment); ce.ObjectStateManager.ChangeObjectState(updateDepartment, EntityState.Modified); ce.SaveChanges(); return(1); //if (ce.SaveChanges != null) //{ //} //return result; }
protected void pageSave(Object sender, BrilliantWMS.ToolbarService.iUCToolbarClient e) { if (checkDuplicate() == "") { try { CustomProfile profile = CustomProfile.GetProfile(); mDepartment ObjDepartment = new mDepartment(); if (hdnDepartmentID.Value == string.Empty) { ObjDepartment.Name = txtDepartment.Text; if (txtSequence.Text != string.Empty) { ObjDepartment.Sequence = Convert.ToInt64(txtSequence.Text); } else { ObjDepartment.Sequence = 0; } if (rbtnYes.Checked == true) { ObjDepartment.Active = "Y"; } else { ObjDepartment.Active = "N"; } ObjDepartment.CreatedBy = profile.Personal.UserID.ToString(); ObjDepartment.CreationDate = DateTime.Now; ObjDepartment.CompanyID = long.Parse(ddlcompanymain.SelectedItem.Value); ObjDepartment.CustomerID = long.Parse(hdncustomerid.Value); ObjDepartment.DeptCode = txtstorecode.Text; int result = DepartmentClient.InsertmDepartment(ObjDepartment, profile.DBConnection._constr); if (result == 1) { WebMsgBox.MsgBox.Show("Record saved successfully"); } BindGrid(); clear(); } else { ObjDepartment = DepartmentClient.GetDepartmentListByID(Convert.ToInt32(hdnDepartmentID.Value), profile.DBConnection._constr); ObjDepartment.Name = txtDepartment.Text; if (txtSequence.Text != string.Empty) { ObjDepartment.Sequence = Convert.ToInt64(txtSequence.Text); } else { ObjDepartment.Sequence = 0; } if (rbtnYes.Checked == true) { ObjDepartment.Active = "Y"; } else { ObjDepartment.Active = "N"; } ObjDepartment.LastModifiedBy = profile.Personal.UserID.ToString(); ObjDepartment.LastModifiedDate = DateTime.Now; ObjDepartment.CompanyID = long.Parse(ddlcompanymain.SelectedItem.Value); ObjDepartment.CustomerID = long.Parse(hdncustomerid.Value); ObjDepartment.DeptCode = txtstorecode.Text; int result = DepartmentClient.updatemDepartment(ObjDepartment, profile.DBConnection._constr); if (result == 1) { WebMsgBox.MsgBox.Show("Record updated successfully"); } BindGrid(); clear(); } } catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, this, "Department Master", "pageSave"); } finally { } } }