示例#1
0
        public Hr_Departments GetById(string strDept_Id, string strCompanyId, string strBranchId)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();


            try
            {
                OpenEntityConnection();
                Hr_Departments DeptsForGetEntity = (from objLinq in objPharmaEntities.Hr_Departments
                                                    where objLinq.Dept_Id == strDept_Id && objLinq.Company_Id == strCompanyId && objLinq.Branch_Id == strBranchId && objLinq.Rec_Status == 0
                                                    select objLinq).FirstOrDefault();
                return(DeptsForGetEntity);
            }
            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();
            }
        }
示例#2
0
        public bool UpdateTask(Hr_Departments objUpdate)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            // bool task = Update(objInsert).Result;
            //return task;
            int rowEffected = 0;

            try
            {
                if (objUpdate != null) //Definsive Programming
                {
                    OpenEntityConnection();
                    Hr_Departments ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Departments
                                                   where objLinq.Dept_Id == objUpdate.Dept_Id && objLinq.Company_Id == objUpdate.Company_Id && objLinq.Branch_Id == objUpdate.Branch_Id
                                                   select objLinq).FirstOrDefault();


                    if (ObjForUpdate != null)
                    {
                        ObjForUpdate.Dept_Name      = objUpdate.Dept_Name;
                        ObjForUpdate.Dept_NameEn    = objUpdate.Dept_NameEn;
                        ObjForUpdate.Dept_NameConv  = objUpdate.Dept_NameConv;
                        ObjForUpdate.Dept_AccountNo = objUpdate.Dept_AccountNo;
                        ObjForUpdate.Admin_Id       = objUpdate.Admin_Id;
                        ObjForUpdate.Dept_Code      = objUpdate.Dept_Code;


                        ObjForUpdate.UpdateUser = objUpdate.UpdateUser;
                        ObjForUpdate.UpdateDate = 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);
            }
        }
示例#3
0
        public async Task <bool> Delete(Hr_Departments objDelete)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            int rowEffected = 0;

            try
            {
                if (objDelete != null) //Definsive Programming
                {
                    OpenEntityConnection();
                    Hr_Departments objForDelete = (from objLinq in objPharmaEntities.Hr_Departments
                                                   where objLinq.Dept_Id == objDelete.Dept_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 = 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);
            }
        }
示例#4
0
        // Calling the method of using Async
        //public  int test() {
        //    int task =  Insert().Result;
        //    return task;

        //}
        public int InsertTask(Hr_Departments 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_Departments.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);
        }
示例#5
0
        public List <Hr_Departments> SelectAllByCompanyAndBranch(string strcomapny, string strbranch)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            List <Hr_Departments> objlist = new List <Hr_Departments>();

            try
            {
                OpenEntityConnection();
                string sql = "select [Company_Id],[Branch_Id],[Dept_Code]";
                sql = sql + ",[Dept_Id],[Dept_Name],[Dept_NameEn],[Dept_NameConv],[Dept_AccountNo],Admin_Id,[InsUser],[InsDate]";
                sql = sql + ",[UpdateUser],UpdateDate,DeleteUser,DeleteDate,Rec_Status,Prefix,Id";

                sql = sql + " from Hr_Departments where Rec_Status = 0 and Company_Id='" + strcomapny + "' and Branch_Id='" + strbranch + "'";
                sql = sql + " Order by Id ";

                //  List<Hr_Departments> objectList = (from objLinq in objPharmaEntities.Hr_Departments
                //                       where objLinq.Rec_Status == 0 && objLinq.Branch_Id == strbranch && objLinq.Company_Id == strcomapny
                //              select objLinq).ToList();



                List <Hr_Departments> objectlist = objPharmaEntities.Database.SqlQuery <Hr_Departments>(sql).ToList();



                if (objectlist != null)
                {
                    foreach (var obj in objectlist)
                    {
                        Hr_Departments obj1 = new Hr_Departments();
                        obj1.Company_Id     = obj.Company_Id;
                        obj1.Branch_Id      = obj.Branch_Id;
                        obj1.Dept_Id        = obj.Dept_Id;
                        obj1.Dept_Code      = obj.Dept_Code;
                        obj1.Admin_Id       = obj.Admin_Id;
                        obj1.Dept_Name      = obj.Dept_Name;
                        obj1.Dept_NameEn    = obj.Dept_NameEn;
                        obj1.Dept_NameConv  = obj.Dept_NameConv;
                        obj1.Dept_AccountNo = obj.Dept_AccountNo;
                        obj1.InsUser        = obj.InsUser;
                        obj1.InsDate        = obj.InsDate;
                        obj1.UpdateUser     = obj.UpdateUser;
                        obj1.UpdateDate     = obj.UpdateDate;
                        obj1.DeleteUser     = obj.DeleteUser;
                        obj1.DeleteDate     = obj.DeleteDate;
                        obj1.Rec_Status     = obj.Rec_Status;
                        obj1.Prefix         = obj.Prefix;

                        objlist.Add(obj1);
                    }
                }


                //var str = (from objlinq in objPharmaEntities.Hr_Departments
                //           where objlinq.Rec_Status == 0
                //           && objlinq.Company_Id == strcomapny && objlinq.Branch_Id == strbranch
                //           select objlinq);
                //string sql = ((ObjectQuery)str).ToTraceString();

                return(objlist);
            }
            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();
            }
        }