Example #1
0
        /// <summary>
        /// 修改公共假期设置信息
        /// </summary>
        /// <param name="entVacRd"></param>
        /// <returns></returns>
        public string ModifyVacationSet(T_HR_VACATIONSET entVacRd)
        {
            string strMsg = string.Empty;

            try
            {
                if (entVacRd == null)
                {
                    return("{REQUIREDFIELDS}");
                }


                bool          flag      = false;
                StringBuilder strFilter = new StringBuilder();
                List <string> objArgs   = new List <string>();

                strFilter.Append(" VACATIONID == @0");

                objArgs.Add(entVacRd.VACATIONID);

                VacationSetDAL dalVacationSet = new VacationSetDAL();
                flag = dalVacationSet.IsExistsRd(strFilter.ToString(), objArgs.ToArray());

                if (!flag)
                {
                    return("{NOTFOUND}");
                }

                List <T_HR_OUTPLANDAYS> entOutPlanDays = entVacRd.T_HR_OUTPLANDAYS.ToList();

                T_HR_VACATIONSET entUpdate = dalVacationSet.GetVacationSetRdByMultSearch(strFilter.ToString(), objArgs.ToArray());
                Utility.CloneEntity(entVacRd, entUpdate);
                entUpdate.UPDATEDATE = DateTime.Now;
                dalVacationSet.Update(entUpdate);
                strMsg = "{SAVESUCCESSED}";

                if (entOutPlanDays == null)
                {
                    return(strMsg);
                }

                OutPlanDaysBLL bllOutPlanDays = new OutPlanDaysBLL();
                bllOutPlanDays.DeleteByVacationID(entVacRd.VACATIONID);

                if (entOutPlanDays.Count() == 0)
                {
                    return(strMsg);
                }

                foreach (T_HR_OUTPLANDAYS item in entOutPlanDays)
                {
                    if (item.EntityKey != null)
                    {
                        item.EntityKey = null;  //清除EntityKey不为null的情况
                    }

                    if (item.T_HR_VACATIONSET == null)
                    {
                        item.T_HR_VACATIONSET = entVacRd;
                    }

                    if (!string.IsNullOrEmpty(item.ISADJUSTLEAVE))
                    {
                        if (item.ISADJUSTLEAVE.ToUpper() == "TRUE" || item.ISADJUSTLEAVE == "1")
                        {
                            item.ISADJUSTLEAVE = "1";
                        }
                        else
                        {
                            item.ISADJUSTLEAVE = "0";
                        }
                    }

                    bllOutPlanDays.AddOutPlanDays(item);
                }

                AsyncEventHandler asy = new AsyncEventHandler(reInitAttandeceRecordWithOutWorkDaySet);
                IAsyncResult      ia  = asy.BeginInvoke(entUpdate.VACATIONID, null, null);
                //reInitAttandeceRecordWithOutWorkDaySet(entUpdate.VACATIONID);
            }
            catch (Exception ex)
            {
                strMsg = ex.Message.ToString();
            }

            return(strMsg);
        }
Example #2
0
        /// <summary>
        /// 新增公共假期设置信息
        /// </summary>
        /// <param name="entVacRd"></param>
        /// <returns></returns>
        public string AddVacationSet(T_HR_VACATIONSET entVacRd)
        {
            string strMsg = string.Empty;

            try
            {
                if (entVacRd == null)
                {
                    return("{REQUIREDFIELDS}");
                }

                bool          flag      = false;
                StringBuilder strFilter = new StringBuilder();
                List <string> objArgs   = new List <string>();

                strFilter.Append(" VACATIONNAME == @0");
                strFilter.Append(" && COUNTYTYPE == @1");
                strFilter.Append(" && VACATIONYEAR == @2");

                objArgs.Add(entVacRd.VACATIONNAME);
                objArgs.Add(entVacRd.COUNTYTYPE);
                objArgs.Add(entVacRd.VACATIONYEAR);

                VacationSetDAL dalVacationSet = new VacationSetDAL();
                flag = dalVacationSet.IsExistsRd(strFilter.ToString(), objArgs.ToArray());

                if (flag)
                {
                    return("{ALREADYEXISTSRECORD}");
                }

                List <T_HR_OUTPLANDAYS> entOutPlanDays = entVacRd.T_HR_OUTPLANDAYS.ToList();

                T_HR_VACATIONSET entAdd = new T_HR_VACATIONSET();
                Utility.CloneEntity(entVacRd, entAdd);
                entAdd.CREATEDATE = DateTime.Now;
                entAdd.UPDATEDATE = DateTime.Now;
                dalVacationSet.Add(entAdd);

                OutPlanDaysBLL bllOutPlanDays = new OutPlanDaysBLL();
                if (entOutPlanDays.Count() > 0)
                {
                    foreach (T_HR_OUTPLANDAYS item in entOutPlanDays)
                    {
                        if (item.EntityKey != null)
                        {
                            item.EntityKey = null;  //清除EntityKey不为null的情况
                        }

                        if (item.T_HR_VACATIONSET == null)
                        {
                            item.T_HR_VACATIONSET = entAdd;
                        }

                        if (!string.IsNullOrEmpty(item.ISADJUSTLEAVE))
                        {
                            if (item.ISADJUSTLEAVE.ToUpper() == "TRUE" || item.ISADJUSTLEAVE == "1")
                            {
                                item.ISADJUSTLEAVE = "1";
                            }
                            else
                            {
                                item.ISADJUSTLEAVE = "0";
                            }
                        }

                        bllOutPlanDays.AddOutPlanDays(item);
                    }
                }

                AsyncEventHandler asy = new AsyncEventHandler(reInitAttandeceRecordWithOutWorkDaySet);
                IAsyncResult      ia  = asy.BeginInvoke(entVacRd.VACATIONID, null, null);

                strMsg = "{SAVESUCCESSED}";
            }
            catch (Exception ex)
            {
                strMsg = ex.Message.ToString();
                Tracer.Debug(ex.ToString());
            }

            return(strMsg);
        }