public async Task <int> Insert(Hr_EmpRewardRequest objInsert) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); int RowEffected = 0; try { if (objInsert != null) { OpenEntityConnection(); objInsert.InsDate = DateTime.Now;//DateTime.Today; objPharmaEntities.Hr_EmpRewardRequest.Add(objInsert); 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(); } return(RowEffected); }
public Hr_EmpRewardRequest GetRequestByHdrId(string strCompanyNo, string strBranchNo, Guid RequestHdrId) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); string sql = "select Rec_Hdr_Id,ReferenceNo,Request_Id,Rec_No,TransDate,InsUser,InsDate,Company_Id,Branch_Id"; sql = sql + ",Emp_Serial_No,DeliveredDate,RewardType,RewardValue,RewardReason_Id,Notes,DocumentPath,Order_Status,Commissioner_Serial_no"; sql = sql + " from Hr_EmpRewardRequest where Company_Id='" + strCompanyNo + "' and Branch_Id='" + strBranchNo + "' and Rec_Hdr_Id = '" + RequestHdrId + "'"; Hr_EmpRewardRequest obj = objPharmaEntities.Database.SqlQuery <Hr_EmpRewardRequest>(sql).FirstOrDefault(); return(obj); // EmpRewardRequestDL objectList = new EmpRewardRequestDL(); //Hr_EmpRewardRequest obj = (from objLinq in objPharmaEntities.Hr_EmpRewardRequest // where objLinq.Company_Id == strCompanyNo && objLinq.Branch_Id==strBranchNo && objLinq.Rec_Hdr_Id == RequestHdrId // select objLinq).FirstOrDefault(); // select new // { // Rec_Hdr_Id = objLinq.Rec_Hdr_Id, // ReferenceNo = objLinq.ReferenceNo, // Request_Id = objLinq.Request_Id, // Emp_Serial_No = objLinq.Emp_Serial_No, // FromDate = objLinq.FromDate, // ToDate = objLinq.ToDate, // Notes = objLinq.Notes, // PlaceOfResidence = objLinq.PlaceOfResidence, // DocumentPath = objLinq.DocumentPath, // Order_Status = objLinq.Order_Status // }); //Hr_EmpRewardRequest obj = objPharmaEntities.Hr_EmpRewardRequest // .Where(objLinq => objLinq.Company_Id == strCompanyNo && objLinq.Branch_Id == strBranchNo && objLinq.Rec_Hdr_Id == RequestHdrId) // .Select( // objLinq => // new // { // Rec_Hdr_Id = objLinq.Rec_Hdr_Id, // ReferenceNo = objLinq.ReferenceNo, // Request_Id = objLinq.Request_Id, // Emp_Serial_No = objLinq.Emp_Serial_No, // FromDate = objLinq.FromDate, // ToDate = objLinq.ToDate, // Notes = objLinq.Notes, // PlaceOfResidence = objLinq.PlaceOfResidence, // DocumentPath = objLinq.DocumentPath, // Order_Status = objLinq.Order_Status // }); // return objLinq; //Rec_No ,ReferenceNo ,Request_Id //,Company_Id ,Branch_Id ,Emp_Serial_No ,TransDate ,FromDate ,ToDate ,BackDate ,Notes ,InsUser ,InsDate ,Order_Status ,PlaceOfResidence ,DocumentPath ,RequestTypeName ,StatusName } 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(); } }