Example #1
0
        public Hr_Branches GetById(string Branch_ID)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            try
            {
                OpenEntityConnection();
                Hr_Branches BranchesForGetEntity = (from objLinq in objPharmaEntities.Hr_Branches
                                                    where objLinq.Branch_Id == Branch_ID && objLinq.Rec_Status == 0
                                                    select objLinq).FirstOrDefault();
                return(BranchesForGetEntity);
            }
            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();
            }
        }
Example #2
0
        // Calling the method of using Async
        //public  int test() {
        //    int task =  Insert().Result;
        //    return task;

        //}
        public int InsertTask(Hr_Branches 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_Branches.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);
        }
Example #3
0
        public bool DeleteTask(Hr_Branches 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_Branches objForDelete = (from objLinq in objPharmaEntities.Hr_Branches
                                                where objLinq.Branch_Id == objDelete.Branch_Id && objLinq.Company_Id == objDelete.Company_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);
            }
        }
Example #4
0
        public async Task <bool> Update(Hr_Branches objUpdate)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            int rowEffected = 0;

            try
            {
                if (objUpdate != null) //Definsive Programming
                {
                    OpenEntityConnection();
                    Hr_Branches ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Branches
                                                where objLinq.Branch_Id == objUpdate.Branch_Id && objLinq.Company_Id == objUpdate.Company_Id
                                                select objLinq).FirstOrDefault();
                    ObjForUpdate.Branch_Name      = objUpdate.Branch_Name;
                    ObjForUpdate.Branch_NameEn    = objUpdate.Branch_NameEn;
                    ObjForUpdate.Branch_Code      = objUpdate.Branch_Code;
                    ObjForUpdate.Branch_AccountNo = objUpdate.Branch_AccountNo;
                    ObjForUpdate.Company_Id       = objUpdate.Company_Id;
                    ObjForUpdate.Country_Id       = objUpdate.Country_Id;
                    ObjForUpdate.City_Id          = objUpdate.City_Id;
                    ObjForUpdate.Currency_Id      = objUpdate.Currency_Id;
                    ObjForUpdate.StreetName       = objUpdate.StreetName;
                    ObjForUpdate.Buiding_Number   = objUpdate.Buiding_Number;
                    ObjForUpdate.P_O_Box          = objUpdate.P_O_Box;
                    ObjForUpdate.Postal_Code      = objUpdate.Postal_Code;
                    ObjForUpdate.Phone1           = objUpdate.Phone1;
                    ObjForUpdate.Phone2           = objUpdate.Phone2;
                    ObjForUpdate.Phone3           = objUpdate.Phone3;
                    ObjForUpdate.Fax              = objUpdate.Fax;
                    ObjForUpdate.Email            = objUpdate.Email;
                    ObjForUpdate.ExtenstionTel1   = objUpdate.ExtenstionTel1;
                    ObjForUpdate.ExtenstionTel2   = objUpdate.ExtenstionTel2;
                    ObjForUpdate.ExtenstionTel3   = objUpdate.ExtenstionTel3;
                    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);
            }
        }