Пример #1
0
        public Hr_Firms GetById(string Firm_ID)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            try
            {
                OpenEntityConnection();
                Hr_Firms CompaniesForGetEntity = (from objLinq in objPharmaEntities.Hr_Firms
                                                  where objLinq.Firm_Id == Firm_ID && objLinq.Rec_Status == 0
                                                  select objLinq).FirstOrDefault();
                return(CompaniesForGetEntity);
            }
            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
        // Calling the method of using Async
        //public  int test() {
        //    int task =  Insert().Result;
        //    return task;

        //}
        public int InsertTask(Hr_Firms 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_Firms.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);
        }
Пример #3
0
        public async Task <bool> Update(Hr_Firms objUpdate)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            int rowEffected = 0;

            try
            {
                if (objUpdate != null) //Definsive Programming
                {
                    OpenEntityConnection();
                    Hr_Firms ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Firms
                                             where objLinq.Firm_Id == objUpdate.Firm_Id
                                             select objLinq).FirstOrDefault();
                    if (ObjForUpdate != null)
                    {
                        ObjForUpdate.Firm_Name        = objUpdate.Firm_Name;
                        ObjForUpdate.Firm_NameEn      = objUpdate.Firm_NameEn;
                        ObjForUpdate.Firm_Code        = objUpdate.Firm_Code;
                        ObjForUpdate.Firm_AccountNo   = objUpdate.Firm_AccountNo;
                        ObjForUpdate.Prefix           = objUpdate.Prefix;
                        ObjForUpdate.Field_AR         = objUpdate.Field_AR;
                        ObjForUpdate.Field_En         = objUpdate.Field_En;
                        ObjForUpdate.Logo_Path        = objUpdate.Logo_Path;
                        ObjForUpdate.Small_Logo_Path  = objUpdate.Small_Logo_Path;
                        ObjForUpdate.ResponsibleEmpId = objUpdate.ResponsibleEmpId;

                        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);
            }
        }
Пример #4
0
        public bool DeleteTask(Hr_Firms 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_Firms objForDelete = (from objLinq in objPharmaEntities.Hr_Firms
                                             where objLinq.Firm_Id == objDelete.Firm_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);
            }
        }