Esempio n. 1
0
 public string SaveChanges(string jsonString)
 {
     try
     {
         JsonSerializerSettings st = new JsonSerializerSettings();
         st.DateTimeZoneHandling = DateTimeZoneHandling.Local;
         ReturnFeeEntity  entity  = JsonConvert.DeserializeObject <ReturnFeeEntity>(jsonString, st);
         ReturnFeeManager service = new ReturnFeeManager();
         if (string.IsNullOrEmpty(entity.iGuid))
         {
             entity.iCreatedBy = SessionHelper.CurrentUser.UserName;
             entity.iUpdatedBy = SessionHelper.CurrentUser.UserName;
             service.Insert(entity);
         }
         else
         {
             entity.iUpdatedBy = SessionHelper.CurrentUser.UserName;
             service.Update(entity);
         }
         return("success");
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
Esempio n. 2
0
        private List <ReturnFeeModel> GetExportData()
        {
            string paraString = Request.Params["searchpara"];
            Dictionary <string, string> paraDic = JsonConvert.DeserializeObject <Dictionary <string, string> >(paraString);

            Dictionary <string, string> bizParaDic = new Dictionary <string, string>();

            bizParaDic.Add("search", paraDic["search"]);
            paraDic.Remove("search");
            bizParaDic.Add("editType", paraDic["sEditType"]);
            paraDic.Remove("sEditType");

            foreach (var item in paraDic)
            {
                if (item.Key.EndsWith("2"))
                {
                    continue;
                }
                if (paraDic.ContainsKey(item.Key + "2"))
                {
                    bizParaDic.Add("i" + item.Key.Substring(1, item.Key.Length - 1) + "[d]", item.Value + "§" + paraDic[item.Key + "2"]);
                }
                else
                {
                    bizParaDic.Add("i" + item.Key.Substring(1, item.Key.Length - 1), item.Value);
                }
            }

            ReturnFeeManager      service = new ReturnFeeManager();
            List <ReturnFeeModel> list    = service.GetSearchAll(SessionHelper.CurrentUser.UserType, bizParaDic);

            DicManager dm        = new DicManager();
            var        companies = dm.GetAllCompanies();
            var        projects  = dm.GetAllProjects();
            Dictionary <string, string> comDic = companies.ToDictionary(i => i.iGuid, i => i.iName);
            Dictionary <string, string> proDic = projects.ToDictionary(i => i.iGuid, i => i.iName);

            foreach (var item in list)
            {
                item.iCompany  = comDic[item.iCompany];
                item.iItemName = proDic[item.iItemName];
            }
            return(list);
        }
Esempio n. 3
0
        private void MergeToDB(List <ReturnFeeEntity> list)
        {
            ReturnFeeManager service = new ReturnFeeManager();

            foreach (var item in list)
            {
                if (string.IsNullOrEmpty(item.iGuid))
                {
                    item.iCreatedBy = SessionHelper.CurrentUser.UserName;
                    item.iUpdatedBy = SessionHelper.CurrentUser.UserName;
                    service.Insert(item);
                }
                else
                {
                    item.iUpdatedBy = SessionHelper.CurrentUser.UserName;
                    service.Update(item);
                }
            }
        }
Esempio n. 4
0
 public JsonResult GetReturnFee(string hrguid)
 {
     try
     {
         ReturnFeeManager service = new ReturnFeeManager();
         ReturnFeeModel   entity  = service.GetFirstOrDefault(hrguid);
         return(new JsonResult {
             Data = new { success = true, msg = "msg", data = entity }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
     catch (Exception ex)
     {
         log4net.ILog log = log4net.LogManager.GetLogger(this.GetType());
         log.Error(ex);
         return(new JsonResult {
             Data = new { success = false, msg = ex.ToString() }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
 }
Esempio n. 5
0
        public void GetAllReturnFee()
        {
            try
            {
                //用于序列化实体类的对象
                JavaScriptSerializer jss = new JavaScriptSerializer();
                jss.MaxJsonLength = Int32.MaxValue;
                //请求中携带的条件
                string order     = HttpContext.Request.Params["order"];
                string sort      = HttpContext.Request.Params["sort"];
                string searchKey = HttpContext.Request.Params["search"];
                int    offset    = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0
                int    pageSize  = Convert.ToInt32(HttpContext.Request.Params["limit"]);
                string editType  = HttpContext.Request.Params["sEditType"];

                Dictionary <string, string> bizParaDic = new Dictionary <string, string>();
                bizParaDic.Add("search", searchKey);
                bizParaDic.Add("editType", editType);
                Dictionary <string, string> bizParaDicTemp = new Dictionary <string, string>();

                foreach (string para in HttpContext.Request.Params.Keys)
                {
                    if (para.StartsWith("s") && (ReturnFeeManager.ReturnFeeDic.ContainsValue("i" + para.Substring(1, para.Length - 1)) || (para.Length > 2 && ReturnFeeManager.ReturnFeeDic.ContainsValue("i" + para.Substring(1, para.Length - 2)))))
                    {
                        bizParaDicTemp.Add("i" + para.Substring(1, para.Length - 1), HttpContext.Request.Params[para]);
                    }
                }
                foreach (var item in bizParaDicTemp)
                {
                    if (item.Key.EndsWith("2"))
                    {
                        continue;
                    }
                    if (bizParaDicTemp.ContainsKey(item.Key + "2"))
                    {
                        bizParaDic.Add(item.Key + "[d]", item.Value + "§" + bizParaDicTemp[item.Key + "2"]);
                    }
                    else
                    {
                        bizParaDic.Add(item.Key, item.Value);
                    }
                }

                int total = 0;
                ReturnFeeManager      service = new ReturnFeeManager();
                List <ReturnFeeModel> list    = service.GetSearch(SessionHelper.CurrentUser.UserType, bizParaDic, sort, order, offset, pageSize, out total);

                DicManager dm        = new DicManager();
                var        companies = dm.GetAllCompanies();
                var        projects  = dm.GetAllProjects();
                Dictionary <string, string> comDic = companies.ToDictionary(i => i.iGuid, i => i.iName);
                Dictionary <string, string> proDic = projects.ToDictionary(i => i.iGuid, i => i.iName);
                foreach (var item in list)
                {
                    item.iCompany  = comDic[item.iCompany];
                    item.iItemName = proDic[item.iItemName];
                }

                //给分页实体赋值
                PageModels <ReturnFeeModel> model = new PageModels <ReturnFeeModel>();
                model.total = total;
                if (total % pageSize == 0)
                {
                    model.page = total / pageSize;
                }
                else
                {
                    model.page = (total / pageSize) + 1;
                }

                model.rows = list;

                //将查询结果返回
                HttpContext.Response.Write(jss.Serialize(model));
            }
            catch (Exception ex)
            {
                log4net.ILog log = log4net.LogManager.GetLogger(this.GetType());
                log.Error(ex);
            }
        }
Esempio n. 6
0
        private List <ReturnFeeEntity> ExcelSheetToEntityList(ISheet sheet, ref string errorLog)
        {
            //需要验证权限,如果是普通用户,不能导入已存在的返回信息。
            DicManager       dm        = new DicManager();
            var              companies = dm.GetAllCompanies();
            var              projects  = dm.GetAllProjects();
            ReturnFeeManager service   = new ReturnFeeManager();

            List <ReturnFeeEntity> list = new List <ReturnFeeEntity>();

            Dictionary <string, string> keycolumnp = ReturnFeeManager.ReturnFeeDic;
            Dictionary <string, int>    keycolumns = new Dictionary <string, int>();

            for (int co = 0; co < sheet.GetRow(0).LastCellNum; co++)
            {
                if (keycolumnp.ContainsKey(sheet.GetRow(0).GetCell(co).ToString().Trim()))
                {
                    keycolumns.Add(keycolumnp[sheet.GetRow(0).GetCell(co).ToString().Trim()], co);
                }
            }
            //遍历数据行
            for (int i = (sheet.FirstRowNum + 1), len = sheet.LastRowNum + 1; i < len; i++)
            {
                CompanyEntity   currentCompany = null;
                ProjectEntity   currentProject = null;
                ReturnFeeEntity en             = new ReturnFeeEntity();
                try
                {
                    string project = sheet.GetRow(i).GetCell(keycolumns["iItemName"]).ToString().Trim();
                    string company = sheet.GetRow(i).GetCell(keycolumns["iCompany"]).ToString().Trim();
                    string empcode = sheet.GetRow(i).GetCell(keycolumns["iEmpNo"]).ToString().Trim();
                    string idcard  = sheet.GetRow(i).GetCell(keycolumns["iIdCard"]).ToString().Trim();
                    if (string.IsNullOrEmpty(empcode))
                    {
                        errorLog += "第【" + (i + 1).ToString() + "】行工号不能为空,临时工用-;";
                    }
                    if (!CheckIDCard18(idcard))
                    {
                        errorLog += "第【" + (i + 1).ToString() + "】行身份证号不合法;";
                    }
                    currentCompany = companies.FirstOrDefault(pj => pj.iName == company);
                    currentProject = projects.FirstOrDefault(pj => pj.iName == project);

                    if (currentCompany == null || currentProject == null)
                    {
                        if (currentCompany == null)
                        {
                            errorLog += "第【" + (i + 1).ToString() + "】行公司名称不存在;";
                        }
                        if (currentProject == null)
                        {
                            errorLog += "第【" + (i + 1).ToString() + "】行项目名称不存在;";
                        }
                        if (SessionHelper.CurrentUser.UserType == "普通用户" && currentProject.iGuid != SessionHelper.CurrentUser.CurrentProject)
                        {
                            errorLog += "第【" + (i + 1).ToString() + "】行只能导入您当前所在的项目;";
                        }
                    }
                    else
                    {
                        string hrId = service.GetValidReturnFeeHrId(currentCompany.iGuid, empcode, idcard, currentProject.iGuid);
                        if (string.IsNullOrEmpty(hrId))
                        {
                            errorLog += "第【" + (i + 1).ToString() + "】行在人事里的当前项目中没有给出返费信息;";
                        }
                        else
                        {
                            en = service.FirstOrDefault(hrId);
                            if (en == null)
                            {
                                en             = new ReturnFeeEntity();
                                en.iHRInfoGuid = hrId;
                            }
                            else
                            {
                                if (SessionHelper.CurrentUser.UserType == "普通用户")
                                {
                                    errorLog += "第【" + (i + 1).ToString() + "】行已编辑过,您无权限再修改,请联系管理员!;";
                                }
                            }
                        }
                    }
                }
                catch
                {
                    errorLog += "第【" + (i + 1).ToString() + "】行所在公司,工号,身份证号不能有缺失;";
                }
                foreach (var kvp in keycolumns)
                {
                    if (sheet.GetRow(i).GetCell(kvp.Value) == null || sheet.GetRow(i).GetCell(kvp.Value).ToString() == "" || en.GetType().GetProperty(kvp.Key) == null)
                    {
                        //en.GetType().GetProperty(kvp.Key).SetValue(en, null, null);
                        //空的不填写,保持原数据不变  ,没有该属性就忽略
                    }
                    else
                    {
                        object value = null;
                        ICell  cell  = sheet.GetRow(i).GetCell(kvp.Value);
                        if (cell.CellType == CellType.Blank)
                        {
                            value = "";
                        }
                        else
                        {
                            string propertyName = en.GetType().GetProperty(kvp.Key).PropertyType.FullName.ToLower();
                            if (cell.CellType == CellType.Numeric && HSSFDateUtil.IsCellDateFormatted(cell))
                            {
                                try
                                {
                                    value = sheet.GetRow(i).GetCell(kvp.Value).DateCellValue;
                                }
                                catch (Exception ex)
                                {
                                    errorLog += "第【" + (i + 1).ToString() + "】行,第【" + (kvp.Value + 1).ToString() + "】列不是标准日期格式;";
                                }
                                if (!propertyName.Contains("datetime") && value != null)
                                {
                                    value = ((DateTime)value).ToString("yyyy-MM-dd");
                                }
                            }
                            else
                            {
                                value = sheet.GetRow(i).GetCell(kvp.Value).ToString().Trim();
                                if (propertyName.Contains("datetime") && value != null)
                                {
                                    DateTime dt = DateTime.Now;
                                    if (DateTime.TryParse(value.ToString(), out dt))
                                    {
                                        value = dt;
                                    }
                                    else
                                    {
                                        errorLog += "第【" + (i + 1).ToString() + "】行,第【" + (kvp.Value + 1).ToString() + "】列不是标准日期格式;";
                                    }
                                }
                            }
                        }
                        en.GetType().GetProperty(kvp.Key).SetValue(en, value, null);
                    }
                }


                string[] paidArray = { "已付", "未付" };
                Dictionary <string, string[]> checkdic = new Dictionary <string, string[]>();
                checkdic.Add("一级付款情况$iFirstReturnFeePayment", paidArray);
                checkdic.Add("二级付款情况$iSecondReturnFeePayment", paidArray);
                checkdic.Add("三级付款情况$iThirdReturnFeePayment", paidArray);
                checkdic.Add("四级付款情况$iFourthReturnFeePayment", paidArray);
                checkdic.Add("五级付款情况$iFifthReturnFeePayment", paidArray);


                //是否有效校验

                foreach (var item in checkdic)
                {
                    foreach (var subitem in item.Key.Split('|'))
                    {
                        PropertyInfo property = en.GetType().GetProperty(subitem.Split('$')[1]);
                        if (property.GetValue(en, null) != null && property.GetValue(en, null).ToString() != "" && !item.Value.Contains(property.GetValue(en, null)))
                        {
                            errorLog += "第【" + (i + 1).ToString() + "】行" + subitem.Split('$')[0] + "不合法,只能输入【";
                            foreach (var value in item.Value)
                            {
                                errorLog += value + ",";
                            }
                            errorLog  = errorLog.TrimEnd(',');
                            errorLog += "】;";
                        }
                    }
                }
                list.Add(en);
            }
            return(list);
        }