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

            try
            {
                OpenEntityConnection();
                Hr_Custodies CountriesForGetEntity = (from objLinq in objPharmaEntities.Hr_Custodies
                                                      where objLinq.Custody_Id == Custody_Id && objLinq.Rec_Status == 0
                                                      select objLinq).FirstOrDefault();
                return(CountriesForGetEntity);
            }
            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
        public List <Hr_Custodies> GetCastodyData(string CastodyType)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            try
            {
                OpenEntityConnection();


                List <Hr_Custodies> objectList = new List <Hr_Custodies>();


                object[] param1 =
                {
                    new SqlParameter("@CastodyType", CastodyType),
                };


                var objlist = objPharmaEntities.Database.SqlQuery <Hr_Custodies>("exec dbo.sp_GetCastodyData @CastodyType", param1).ToList();

                foreach (var obj in objlist)
                {
                    Hr_Custodies CustodiesdDL = new Hr_Custodies();
                    CustodiesdDL.Custody_Id       = obj.Custody_Id;
                    CustodiesdDL.Custody_Name     = obj.Custody_Name;
                    CustodiesdDL.Custody_NameEn   = obj.Custody_NameEn;
                    CustodiesdDL.Custody_NameConv = obj.Custody_NameConv;
                    CustodiesdDL.InsUser          = obj.InsUser;
                    CustodiesdDL.InsDate          = obj.InsDate;
                    CustodiesdDL.UpdateUser       = obj.UpdateUser;
                    CustodiesdDL.DeleteUser       = obj.DeleteUser;
                    CustodiesdDL.DeleteDate       = obj.DeleteDate;
                    CustodiesdDL.Rec_Status       = obj.Rec_Status;

                    objectList.Add(CustodiesdDL);
                }



                return(objectList);
            }
            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 bool UpdateTask(Hr_Custodies 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_Custodies ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Custodies
                                                 where objLinq.Custody_Id == objUpdate.Custody_Id
                                                 select objLinq).FirstOrDefault();

                    ObjForUpdate.Custody_Name   = objUpdate.Custody_Name;
                    ObjForUpdate.Custody_NameEn = objUpdate.Custody_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);
            }
        }
Ejemplo n.º 4
0
        public async Task <bool> Delete(Hr_Custodies objDelete)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();

            int rowEffected = 0;

            try
            {
                if (objDelete != null) //Definsive Programming
                {
                    OpenEntityConnection();
                    Hr_Countries objForDelete = (from objLinq in objPharmaEntities.Hr_Countries
                                                 where objLinq.Country_Id == objDelete.Custody_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);
            }
        }
Ejemplo n.º 5
0
        // Calling the method of using Async
        //public  int test() {
        //    int task =  Insert().Result;
        //    return task;

        //}
        public int InsertTask(Hr_Custodies 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;
                    objInsert.InsUser = UserNameProperty;


                    objPharmaEntities.Hr_Custodies.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.º 6
0
        public bool SaveCastodyData(List <Hr_Custodies> objList)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();


            try
            {
                OpenEntityConnection();

                int Result = 0;
                if (objList != null)
                {
                    foreach (var obj in objList)
                    {
                        // data base bind
                        if (obj.Rec_Status == 0)
                        {
                        }
                        //Add
                        else if (obj.Rec_Status == 1)
                        {
                            Hr_Custodies newobj = new Hr_Custodies();
                            newobj.Custody_Id       = GetNewId();
                            newobj.Custody_Name     = obj.Custody_Name;
                            newobj.Custody_NameEn   = obj.Custody_NameEn;
                            newobj.Custody_NameConv = obj.Custody_NameConv;
                            newobj.InsUser          = UserNameProperty;
                            newobj.InsDate          = DateTime.Now;
                            newobj.UpdateUser       = null;
                            newobj.UpdateDate       = null;
                            newobj.DeleteUser       = null;
                            newobj.DeleteDate       = null;



                            objPharmaEntities.Hr_Custodies.Add(newobj);
                            Result = objPharmaEntities.SaveChanges();
                        }
                        //Edit
                        else if (obj.Rec_Status == 2)
                        {
                            if (obj.Custody_Id != null && obj.Custody_Id != "")
                            {
                                Hr_Custodies ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Custodies
                                                             where objLinq.Custody_Id == obj.Custody_Id
                                                             select objLinq).FirstOrDefault();

                                if (ObjForUpdate != null)
                                {
                                    ObjForUpdate.Custody_Name   = obj.Custody_Name;
                                    ObjForUpdate.Custody_NameEn = obj.Custody_NameEn;
                                    ObjForUpdate.UpdateUser     = UserNameProperty;
                                    ObjForUpdate.UpdateDate     = DateTime.Now;



                                    Result = objPharmaEntities.SaveChanges();
                                }
                            }
                            else
                            {
                                Hr_Custodies newobj = new Hr_Custodies();
                                newobj.Custody_Id       = GetNewId();
                                newobj.Custody_Name     = obj.Custody_Name;
                                newobj.Custody_NameEn   = obj.Custody_NameEn;
                                newobj.Custody_NameConv = obj.Custody_NameConv;
                                newobj.InsUser          = UserNameProperty;
                                newobj.InsDate          = DateTime.Now;
                                newobj.UpdateUser       = null;
                                newobj.UpdateDate       = null;
                                newobj.DeleteUser       = null;
                                newobj.DeleteDate       = null;



                                objPharmaEntities.Hr_Custodies.Add(newobj);
                                Result = objPharmaEntities.SaveChanges();
                            }
                        }
                        //Delete
                        else if (obj.Rec_Status == 3)
                        {
                            if (obj.Custody_Id != null && obj.Custody_Id != "")
                            {
                                Hr_Custodies ObjForDelete = (from objLinq in objPharmaEntities.Hr_Custodies
                                                             where objLinq.Custody_Id == obj.Custody_Id
                                                             select objLinq).FirstOrDefault();
                                if (ObjForDelete != null)
                                {
                                    ObjForDelete.Rec_Status = 3;
                                    ObjForDelete.DeleteUser = UserNameProperty;
                                    ObjForDelete.DeleteDate = DateTime.Now;
                                    //  objPharmaEntities.Hr_Custodies.Remove(ObjForDelete);
                                    Result = objPharmaEntities.SaveChanges();
                                }
                            }
                            else
                            {
                            }
                        }
                        else
                        {
                        }
                    }


                    return(Result > 0);
                }
                else
                {
                    return(Result < 0);
                }
            }
            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(false);
            }
            finally
            {
                CloseEntityConnection();
            }
        }