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

        //}
        public int InsertTask(Hr_DocumentTypes 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_DocumentTypes.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.º 2
0
        public Hr_DocumentTypes GetById(string Doc_Type_ID)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            try
            {
                OpenEntityConnection();
                Hr_DocumentTypes DocumentTypesForGetEntity = (from objLinq in objPharmaEntities.Hr_DocumentTypes
                                                              where objLinq.Doc_Type_Id == Doc_Type_ID && objLinq.Rec_Status == 0
                                                              select objLinq).FirstOrDefault();
                return(DocumentTypesForGetEntity);
            }
            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.º 3
0
        public List <Hr_DocumentTypes> GetAll()
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();


            try
            {
                OpenEntityConnection();

                List <Hr_DocumentTypes> objlist = new List <Hr_DocumentTypes>();

                string sql = " Select Doc_Type_Id,Doc_Type_Code,Doc_Type_Name,Doc_Type_NameEn,Doc_Type,Doc_Type_NameConv,InsUser, InsDate,UpdateUser, UpdateDate, Rec_Status, DeleteUser, DeleteDate,Id ";
                sql = sql + " FROM            Hr_DocumentTypes where Rec_Status = 0  ";
                sql = sql + " Order by Id";

                List <Hr_DocumentTypes> objectList = objPharmaEntities.Database.SqlQuery <Hr_DocumentTypes>(sql).ToList();

                if (objectList != null)
                {
                    foreach (var obj in objectList)
                    {
                        Hr_DocumentTypes objHr_DocumentTypes = new Hr_DocumentTypes();
                        objHr_DocumentTypes.Doc_Type_Id       = obj.Doc_Type_Id;
                        objHr_DocumentTypes.Doc_Type_Code     = obj.Doc_Type_Code;
                        objHr_DocumentTypes.Doc_Type_Name     = obj.Doc_Type_Name;
                        objHr_DocumentTypes.Doc_Type_NameEn   = obj.Doc_Type_NameEn;
                        objHr_DocumentTypes.Doc_Type_NameConv = obj.Doc_Type_NameConv;
                        objHr_DocumentTypes.Doc_Type          = obj.Doc_Type;

                        objHr_DocumentTypes.Rec_Status = obj.Rec_Status;

                        objlist.Add(objHr_DocumentTypes);
                    }
                }

                //List<Hr_DocumentTypes> objectList = (from objLinq in objPharmaEntities.Hr_DocumentTypes
                //                            where objLinq.Rec_Status == 0
                //                         select objLinq).ToList();
                return(objlist);
            }
            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.º 4
0
        public bool UpdateTask(Hr_DocumentTypes 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_DocumentTypes ObjForUpdate = (from objLinq in objPharmaEntities.Hr_DocumentTypes
                                                     where objLinq.Doc_Type_Id == objUpdate.Doc_Type_Id
                                                     select objLinq).FirstOrDefault();
                    ObjForUpdate.Doc_Type_Name   = objUpdate.Doc_Type_Name;
                    ObjForUpdate.Doc_Type_NameEn = objUpdate.Doc_Type_NameEn;
                    ObjForUpdate.Doc_Type        = objUpdate.Doc_Type;
                    ObjForUpdate.Doc_Type_Code   = objUpdate.Doc_Type_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);
            }
        }