public async Task <bool> Update(Hr_Branch_Docs_Hdr objUpdate) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); int rowEffected = 0; try { if (objUpdate != null) //Definsive Programming { OpenEntityConnection(); Hr_Branch_Docs_Hdr ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Branch_Docs_Hdr where objLinq.Hdr_Id == objUpdate.Hdr_Id && objLinq.Company_Id == objUpdate.Company_Id && objLinq.Branch_Id == objUpdate.Branch_Id select objLinq).FirstOrDefault(); ObjForUpdate.Doc_Type_Id = objUpdate.Doc_Type_Id; ObjForUpdate.LastFromDate = objUpdate.LastFromDate; ObjForUpdate.LastToDate = objUpdate.LastToDate; ObjForUpdate.LastFromDateHijri = objUpdate.LastFromDateHijri; ObjForUpdate.LastToDateHijri = objUpdate.LastToDateHijri; ObjForUpdate.ToBeNotifyPeriodBefore = objUpdate.ToBeNotifyPeriodBefore; ObjForUpdate.NotifyPeriodType = objUpdate.NotifyPeriodType; ObjForUpdate.ResponsibleEmpIdToNotify = objUpdate.ResponsibleEmpIdToNotify; ObjForUpdate.NotifyMessage = objUpdate.NotifyMessage; ObjForUpdate.NotifyMessageEn = objUpdate.NotifyMessageEn; ObjForUpdate.ActuallDateNotification = objUpdate.ActuallDateNotification; ObjForUpdate.ActuallDateNotificationHijri = objUpdate.ActuallDateNotificationHijri; ObjForUpdate.UseNotifyDateType = objUpdate.UseNotifyDateType; ObjForUpdate.Issue_Place = objUpdate.Issue_Place; ObjForUpdate.Issue_Region = objUpdate.Issue_Region; ObjForUpdate.RegistrationNo = objUpdate.RegistrationNo; ObjForUpdate.Notes = objUpdate.Notes; ObjForUpdate.DocPath = objUpdate.DocPath; ObjForUpdate.UpdateUser = objUpdate.UpdateUser; ObjForUpdate.UpdateDate = DateTime.Now; rowEffected = await objPharmaEntities.SaveChangesAsync(); } } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); rowEffected = -1; ex.InnerException.Message.ToString(); } finally { CloseEntityConnection(); } if (rowEffected > 0) { return(true); } else { return(false); } }
public Hr_Branch_Docs_Hdr GetById(Guid Doc_ID, string strCompany_Id, string strBranch_Id) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); string sql = " Select Hdr_Id, Branch_Doc_Id, Branch_Doc_Code, Company_Id, Branch_Id, Doc_Type_Id, LastFromDate, LastToDate, LastFromDateHijri, LastToDateHijri, "; sql = sql + " ToBeNotifyPeriodBefore, NotifyPeriodType, ResponsibleEmpIdToNotify, NotifyMessage, NotifyMessageEn, ActuallDateNotification, ActuallDateNotificationHijri, "; sql = sql + " UseNotifyDateType, InsUser, InsDate, Issue_Place, Issue_Region, UpdateUser, UpdateDate, Rec_Status, DeleteUser, DeleteDate, Notes,DocPath,SendNotify,RegistrationNo"; sql = sql + " FROM Hr_Branch_Docs_Hdr where Rec_Status = 0 and Hdr_Id ='" + Doc_ID + "' and Company_Id='" + strCompany_Id + "' and Branch_Id='" + strBranch_Id + "'"; Hr_Branch_Docs_Hdr objectlist = objPharmaEntities.Database.SqlQuery <Hr_Branch_Docs_Hdr>(sql).FirstOrDefault(); //Hr_Branch_Docs_Hdr BranchDocumentsForGetEntity = (from objLinq in objPharmaEntities.Hr_Branch_Docs_Hdr // where objLinq.Hdr_Id == Doc_ID && objLinq.Company_Id == strCompany_Id && objLinq.Branch_Id == strBranch_Id // select objLinq).FirstOrDefault(); return(objectlist); } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); ex.InnerException.Message.ToString(); return(null); } finally { CloseEntityConnection(); } }
// Calling the method of using Async //public int test() { // int task = Insert().Result; // return task; //} public int InsertTask(Hr_Branch_Docs_Hdr objInsert) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); //int result = Insert(objInsert).Result; //return result; int RowEffected = 0; try { if (objInsert != null) { OpenEntityConnection(); objInsert.InsDate = DateTime.Now;//DateTime.Today; objPharmaEntities.Hr_Branch_Docs_Hdr.Add(objInsert); RowEffected = objPharmaEntities.SaveChanges(); } } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); RowEffected = -1; ex.InnerException.Message.ToString(); } finally { CloseEntityConnection(); } return(RowEffected); }
public bool DeleteTask(Hr_Branch_Docs_Hdr objDelete) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); // bool task = Delete(objInsert).Result; // return task; int rowEffected = 0; try { if (objDelete != null) //Definsive Programming { OpenEntityConnection(); Hr_Branch_Docs_Hdr objForDelete = (from objLinq in objPharmaEntities.Hr_Branch_Docs_Hdr where objLinq.Hdr_Id == objDelete.Hdr_Id && objLinq.Company_Id == objDelete.Company_Id && objLinq.Branch_Id == objDelete.Branch_Id select objLinq).FirstOrDefault(); objForDelete.Rec_Status = 1; objForDelete.DeleteUser = objDelete.DeleteUser; objForDelete.DeleteDate = DateTime.Now; rowEffected = objPharmaEntities.SaveChanges(); } } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); rowEffected = -1; ex.InnerException.Message.ToString(); } finally { CloseEntityConnection(); } if (rowEffected > 0) { return(true); } else { return(false); } }