Esempio n. 1
0
 public bool Validate(string type, YwSpec entity, ref string errmsg)
 {
     switch (type)
     {
     case "all":
         #region validate all
         if (entity.SpecName == "")
         {
             errmsg = "特殊类型不能为空";
             return(false);
         }
         if (entity.Jqxfv < 0 || entity.Jqxfv > 100)
         {
             errmsg = "交强费率超出范围,只能在0和100之间";
             return(false);
         }
         if (entity.Syxfv < 0 || entity.Syxfv > 100)
         {
             errmsg = "商业费率超出范围,只能在0和100之间";
             return(false);
         }
         #endregion
         break;
     }
     return(true);
 }
Esempio n. 2
0
        public bool CheckExist(string specName)
        {
            YwSpec t1 = new YwSpec();

            t1.SpecName = specName;
            int count = baseDao.Count(t1);

            if (count > 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        private void CreateRow(IRow row, YwSpec entity)
        {
            ICell cell = row.CreateCell(0);

            cell.SetCellValue(entity.SpecName);
            cell.SetCellType(CellType.String);
            ICell cell1 = row.CreateCell(1);

            cell1.SetCellType(CellType.String);
            cell1.SetCellValue(entity.Syxfv.ToString());
            ICell cell2 = row.CreateCell(2);

            cell2.SetCellType(CellType.String);
            cell2.SetCellValue(entity.Jqxfv.ToString());
        }
Esempio n. 4
0
        public XSSFWorkbook Export()
        {
            XSSFWorkbook book  = new XSSFWorkbook();
            ISheet       sheet = book.CreateSheet("specExport");
            IRow         row   = sheet.CreateRow(0);

            CreateHead(row);
            YwSpec         param = new YwSpec();
            IList <YwSpec> list  = baseDao.List(param);
            int            i     = 0;

            foreach (YwSpec temp in list)
            {
                i += 1;
                IRow rowT = sheet.CreateRow(i);
                CreateRow(rowT, temp);
            }

            return(book);
        }
Esempio n. 5
0
        private bool Save(Framework.Task.Task task, ref string errmsg)
        {
            bool result = true;

            YwSpecService service = new YwSpecService();
            YwSpec        entity  = task.Entity as YwSpec;

            if (service.Validate("all", entity, ref errmsg) == false)
            {
                return(false);
            }
            BaseDao baseDao = new BaseDao();

            if (entity.Did > 0)
            {
                baseDao.Update(entity);
            }
            else
            {
                YwSpec temp = new YwSpec();
                temp.SpecName = entity.SpecName;
                int count = baseDao.Count(temp);
                if (count > 0)
                {
                    errmsg = "该特殊情况已经被定义";
                    return(false);
                }
                baseDao.Insert(entity);
            }

            if (result == true)
            {
                errmsg            = "保存成功";
                task.ParentRebind = true;
                task.IsClose      = true;
            }
            return(result);
        }
Esempio n. 6
0
        private bool Delete(Framework.Task.Task task, ref string errmsg)
        {
            YwSpec delModel = new YwSpec();

            delModel.SysKey = task.CommandArgument;
            BaseDao baseDao = new BaseDao();

            try
            {
                baseDao.Delete(delModel);
            }
            catch (Exception ex)
            {
                errmsg = ex.Message;
                return(false);
            }
            if (errmsg != "")
            {
                return(false);
            }
            errmsg      = "删除成功";
            task.Rebind = true;
            return(true);
        }
Esempio n. 7
0
        private void DealRow(int rowIndex, IRow row)
        {
            YwSpec temp = new YwSpec();

            for (int index = 0; index < row.Cells.Count; index++)
            {
                ICell cell = row.GetCell(index);
                cell.SetCellType(CellType.String);
                switch (index)
                {
                case 0:
                    try
                    {
                        if (cell.StringCellValue.Trim() == "")
                        {
                            return;
                        }
                        temp.SpecName = cell.StringCellValue.Trim();
                        if (temp.SpecName == "")
                        {
                            throw new Exception("第" + rowIndex + "行    特殊类型 不能为空");
                        }
                    }
                    catch
                    {
                        throw new Exception("第" + rowIndex + "行    特殊类型 不能为空");
                    }
                    break;

                case 1:
                    decimal temp1 = 0;
                    try
                    {
                        temp1 = decimal.Parse(cell.StringCellValue.Trim());
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("第" + rowIndex + "行    商业险费率(%)格式不正确,应该在0和100之间的数字");
                    }
                    if (temp1 < 0 || temp1 > 100)
                    {
                        throw new Exception("第" + rowIndex + "行    商业险费率(%)应该在0和100之间");
                    }
                    temp.Syxfv = temp1;
                    break;

                case 2:
                    decimal temp2;
                    try
                    {
                        temp2 = decimal.Parse(cell.StringCellValue.Trim());
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("第" + rowIndex + "行    交强险费率(%)格式不正确,应该在0和100之间的数字");
                    }
                    if (temp2 < 0 || temp2 > 100)
                    {
                        throw new Exception("第" + rowIndex + "行    交强险费率(%)应该在0和100之间");
                    }
                    temp.Jqxfv = temp2;
                    break;
                }
            }
            if (this.CheckExist(temp.SpecName) == true)
            {
                throw new Exception("第" + rowIndex + " 行  [" + temp.SpecName + "]该特殊类型已经被定义");
            }
            baseDao.Insert(temp);
        }