Esempio n. 1
0
        // Calling the method of using Async
        //public  int test() {
        //    int task =  Insert().Result;
        //    return task;

        //}
        public int InsertTask(Hr_Currencies 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_Currencies.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);
        }
Esempio n. 2
0
        public Hr_Currencies GetById(string Currency_ID)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            try
            {
                OpenEntityConnection();
                Hr_Currencies CurrenciesForGetEntity = (from objLinq in objPharmaEntities.Hr_Currencies
                                                        where objLinq.Currency_Id == Currency_ID && objLinq.Rec_Status == 0
                                                        select objLinq).FirstOrDefault();
                return(CurrenciesForGetEntity);
            }
            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();
            }
        }
Esempio n. 3
0
        public bool UpdateTask(Hr_Currencies 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_Currencies ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Currencies
                                                  where objLinq.Currency_Id == objUpdate.Currency_Id
                                                  select objLinq).FirstOrDefault();
                    if (ObjForUpdate != null)
                    {
                        ObjForUpdate.Currency_Code   = objUpdate.Currency_Code;
                        ObjForUpdate.Currency_Name   = objUpdate.Currency_Name;
                        ObjForUpdate.Currency_NameEn = objUpdate.Currency_NameEn;
                        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);
            }
        }
Esempio n. 4
0
        public async Task <bool> Delete(Hr_Currencies objDelete)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            int rowEffected = 0;

            try
            {
                if (objDelete != null) //Definsive Programming
                {
                    OpenEntityConnection();
                    Hr_Currencies objForDelete = (from objLinq in objPharmaEntities.Hr_Currencies
                                                  where objLinq.Currency_Id == objDelete.Currency_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);
            }
        }