Ejemplo n.º 1
0
        public Hr_Locations GetById(string Location_ID)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            try
            {
                OpenEntityConnection();
                Hr_Locations LocationesForGetEntity = (from objLinq in objPharmaEntities.Hr_Locations
                                                       where objLinq.Location_Id == Location_ID && objLinq.Rec_Status == 0
                                                       select objLinq).FirstOrDefault();
                return(LocationesForGetEntity);
            }
            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();
            }
        }
Ejemplo n.º 2
0
        // Calling the method of using Async
        //public  int test() {
        //    int task =  Insert().Result;
        //    return task;

        //}
        public int InsertTask(Hr_Locations 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_Locations.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);
        }
Ejemplo n.º 3
0
        public bool DeleteTask(Hr_Locations 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_Locations objForDelete = (from objLinq in objPharmaEntities.Hr_Locations
                                                 where objLinq.Location_Id == objDelete.Location_Id && 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);
            }
        }
Ejemplo n.º 4
0
        public async Task <bool> Update(Hr_Locations objUpdate)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            int rowEffected = 0;

            try
            {
                if (objUpdate != null) //Definsive Programming
                {
                    OpenEntityConnection();
                    Hr_Locations ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Locations
                                                 where objLinq.Location_Id == objUpdate.Location_Id && objLinq.Firm_Id == objUpdate.Firm_Id
                                                 select objLinq).FirstOrDefault();
                    ObjForUpdate.Location_Name      = objUpdate.Location_Name;
                    ObjForUpdate.Location_NameEn    = objUpdate.Location_NameEn;
                    ObjForUpdate.Location_Code      = objUpdate.Location_Code;
                    ObjForUpdate.Location_AccountNo = objUpdate.Location_AccountNo;
                    ObjForUpdate.Firm_Id            = objUpdate.Firm_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);
            }
        }