コード例 #1
0
ファイル: ProjectsDAL.cs プロジェクト: atheltree-dev/AthelHR
        public Hr_Projects GetById(string strProject_Id, string strCompanyId, string strBranchId)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();


            try
            {
                OpenEntityConnection();
                Hr_Projects ProjectsForGetEntity = (from objLinq in objPharmaEntities.Hr_Projects
                                                    where objLinq.Project_Id == strProject_Id && objLinq.Company_Id == strCompanyId && objLinq.Branch_Id == strBranchId && objLinq.Rec_Status == 0
                                                    select objLinq).FirstOrDefault();
                return(ProjectsForGetEntity);
            }
            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
ファイル: ProjectsDAL.cs プロジェクト: atheltree-dev/AthelHR
        public bool UpdateTask(Hr_Projects 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_Projects ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Projects
                                                where objLinq.Project_Id == objUpdate.Project_Id && objLinq.Company_Id == objUpdate.Company_Id && objLinq.Branch_Id == objUpdate.Branch_Id
                                                select objLinq).FirstOrDefault();


                    if (ObjForUpdate != null)
                    {
                        ObjForUpdate.Project_Name     = objUpdate.Project_Name;
                        ObjForUpdate.Project_NameEn   = objUpdate.Project_NameEn;
                        ObjForUpdate.Project_NameConv = objUpdate.Project_NameConv;
                        ObjForUpdate.Project_Code     = objUpdate.Project_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
ファイル: ProjectsDAL.cs プロジェクト: atheltree-dev/AthelHR
        public async Task <bool> Delete(Hr_Projects objDelete)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            int rowEffected = 0;

            try
            {
                if (objDelete != null) //Definsive Programming
                {
                    OpenEntityConnection();
                    Hr_Projects objForDelete = (from objLinq in objPharmaEntities.Hr_Projects
                                                where objLinq.Project_Id == objDelete.Project_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
ファイル: ProjectsDAL.cs プロジェクト: atheltree-dev/AthelHR
        // Calling the method of using Async
        //public  int test() {
        //    int task =  Insert().Result;
        //    return task;

        //}
        public int InsertTask(Hr_Projects 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_Projects.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);
        }