Esempio n. 1
0
        public bool SaveDelayRecordData(List <AbsenceRecordDL> 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.RecStatus == 0)
                        {
                        }
                        //Add
                        else if (obj.RecStatus == 1)
                        {
                            Hr_EmpAbsenceRecord newobj = new Hr_EmpAbsenceRecord();
                            newobj.Rec_Hdr_Id    = GetNewHeaderId();
                            newobj.Company_Id    = obj.Company_Id;
                            newobj.Branch_Id     = obj.Branch_Id;
                            newobj.Emp_Serial_No = obj.Emp_Serial_No;
                            newobj.TransDate     = obj.TransDate;
                            newobj.InsUser       = UserNameProperty;
                            newobj.InsDate       = DateTime.Now;
                            newobj.HireItem_Id   = "0011";
                            newobj.Confirmed     = 0;


                            objPharmaEntities.Hr_EmpAbsenceRecord.Add(newobj);
                            Result = objPharmaEntities.SaveChanges();
                        }
                        //Edit
                        else if (obj.RecStatus == 2)
                        {
                            if (obj.Rec_Hdr_Id != Guid.Empty)
                            {
                                Hr_EmpAbsenceRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpAbsenceRecord
                                                                    where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id
                                                                    select objLinq).FirstOrDefault();

                                if (ObjForUpdate != null)
                                {
                                    ObjForUpdate.TransDate     = obj.TransDate;
                                    ObjForUpdate.Emp_Serial_No = obj.Emp_Serial_No;



                                    Result = objPharmaEntities.SaveChanges();
                                }
                            }
                            else
                            {
                                Hr_EmpAbsenceRecord newobj = new Hr_EmpAbsenceRecord();
                                newobj.Rec_Hdr_Id    = GetNewHeaderId();
                                newobj.Company_Id    = obj.Company_Id;
                                newobj.Branch_Id     = obj.Branch_Id;
                                newobj.Emp_Serial_No = obj.Emp_Serial_No;
                                newobj.TransDate     = obj.TransDate;
                                newobj.InsUser       = UserNameProperty;
                                newobj.InsDate       = DateTime.Now;
                                newobj.HireItem_Id   = "0011";
                                newobj.Confirmed     = 0;



                                objPharmaEntities.Hr_EmpAbsenceRecord.Add(newobj);
                                Result = objPharmaEntities.SaveChanges();
                            }
                        }
                        //Delete
                        else if (obj.RecStatus == 3)
                        {
                            if (obj.Rec_Hdr_Id != Guid.Empty)
                            {
                                Hr_EmpAbsenceRecord ObjForDelete = (from objLinq in objPharmaEntities.Hr_EmpAbsenceRecord
                                                                    where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id
                                                                    select objLinq).FirstOrDefault();
                                if (ObjForDelete != null)
                                {
                                    objPharmaEntities.Hr_EmpAbsenceRecord.Remove(ObjForDelete);
                                    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();
            }
        }
Esempio n. 2
0
        public bool SaveRecordData(List <RecordsConfirmationDL> objList)
        {
            StackFrame stackFrame = new StackFrame();
            MethodBase methodBase = stackFrame.GetMethod();


            try
            {
                OpenEntityConnection();

                int Result = 0;
                if (objList != null)
                {
                    foreach (var obj in objList)
                    {
                        if (obj.Record_ID == 0)
                        {
                            if (obj.Rec_Hdr_Id != Guid.Empty)
                            {
                                Hr_EmpOverTimeRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpOverTimeRecord
                                                                     where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id
                                                                     select objLinq).FirstOrDefault();

                                if (ObjForUpdate != null)
                                {
                                    ObjForUpdate.Confirmed = 1;
                                    Result = objPharmaEntities.SaveChanges();
                                }
                            }
                        }
                        else if (obj.Record_ID == 1)
                        {
                            if (obj.Rec_Hdr_Id != Guid.Empty)
                            {
                                Hr_EmpPermissionRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpPermissionRecord
                                                                       where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id
                                                                       select objLinq).FirstOrDefault();

                                if (ObjForUpdate != null)
                                {
                                    ObjForUpdate.Confirmed = 1;
                                    Result = objPharmaEntities.SaveChanges();
                                }
                            }
                        }

                        else if (obj.Record_ID == 2)
                        {
                            if (obj.Rec_Hdr_Id != Guid.Empty)
                            {
                                Hr_EmpDelayRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpDelayRecord
                                                                  where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id
                                                                  select objLinq).FirstOrDefault();

                                if (ObjForUpdate != null)
                                {
                                    ObjForUpdate.Confirmed = 1;
                                    Result = objPharmaEntities.SaveChanges();
                                }
                            }
                        }

                        else if (obj.Record_ID == 3)
                        {
                            if (obj.Rec_Hdr_Id != Guid.Empty)
                            {
                                Hr_EmpVactionRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpVactionRecord
                                                                    where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id
                                                                    select objLinq).FirstOrDefault();

                                if (ObjForUpdate != null)
                                {
                                    ObjForUpdate.Confirmed = 1;
                                    Result = objPharmaEntities.SaveChanges();
                                }
                            }
                        }

                        else if (obj.Record_ID == 4)
                        {
                            if (obj.Rec_Hdr_Id != Guid.Empty)
                            {
                                Hr_EmpAbsenceRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpAbsenceRecord
                                                                    where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id
                                                                    select objLinq).FirstOrDefault();

                                if (ObjForUpdate != null)
                                {
                                    ObjForUpdate.Confirmed = 1;
                                    Result = objPharmaEntities.SaveChanges();
                                }
                            }
                        }
                        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();
            }
        }