public bool SaveDelayRecordData(List<DelayRecordDL> 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_EmpDelayRecord newobj = new Hr_EmpDelayRecord();
                            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.Delay_Period = obj.Delay_Period;
                            newobj.InsUser = UserNameProperty;
                            newobj.InsDate = DateTime.Now;
                            newobj.HireItem_Id = "0011";
                            newobj.Confirmed = 0;


                            objPharmaEntities.Hr_EmpDelayRecord.Add(newobj);
                            Result = objPharmaEntities.SaveChanges();

                        }
                        //Edit
                        else if (obj.RecStatus == 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.TransDate = obj.TransDate;
                                    ObjForUpdate.Delay_Period = obj.Delay_Period;
                                    ObjForUpdate.Emp_Serial_No = obj.Emp_Serial_No;
                                



                                    Result = objPharmaEntities.SaveChanges();
                                }
                            }
                            else
                            {
                                Hr_EmpDelayRecord newobj = new Hr_EmpDelayRecord();
                                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.Delay_Period = obj.Delay_Period;
                                newobj.InsUser = UserNameProperty;
                                newobj.InsDate = DateTime.Now;
                                newobj.HireItem_Id = "0011";
                                newobj.Confirmed = 0;



                                objPharmaEntities.Hr_EmpDelayRecord.Add(newobj);
                                Result = objPharmaEntities.SaveChanges();
                            }

                        }
                        //Delete
                        else if (obj.RecStatus == 3 )
                        {
                            if (obj.Rec_Hdr_Id != Guid.Empty)
                            {
                                Hr_EmpDelayRecord ObjForDelete = (from objLinq in objPharmaEntities.Hr_EmpDelayRecord
                                                                  where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id
                                                                     select objLinq).FirstOrDefault();
                                if (ObjForDelete != null)
                                {
                                    objPharmaEntities.Hr_EmpDelayRecord.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();
            }



        }
Exemple #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();
            }
        }