Exemplo n.º 1
0
 public bool Validate(string type, YwTxjs entity, ref string errmsg)
 {
     switch (type)
     {
     case "all":
         #region validate all
         if (entity.Txm.Trim() == "")
         {
             errmsg = "推修码不能为空";
             return(false);
         }
         if (entity.Xs.Trim() == "")
         {
             entity.Xs = "0";
         }
         else
         {
             try
             {
                 decimal temp = decimal.Parse(entity.Xs);
             }
             catch
             {
                 errmsg = "系数格式不正确,应该是为数字";
                 return(false);
             }
         }
         #endregion
         break;
     }
     return(true);
 }
Exemplo n.º 2
0
        public bool CheckExist(string Txm)
        {
            YwTxjs t1 = new YwTxjs();

            t1.Txm = Txm;
            int count = baseDao.Count(t1);

            if (count > 0)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        public XSSFWorkbook Export()
        {
            XSSFWorkbook book  = new XSSFWorkbook();
            ISheet       sheet = book.CreateSheet("specExport");
            IRow         row   = sheet.CreateRow(0);

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

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

            return(book);
        }
Exemplo n.º 4
0
        private void CreateRow(IRow row, YwTxjs entity)
        {
            ICell cell = row.CreateCell(0);

            cell.SetCellValue(entity.Txm);
            cell.SetCellType(CellType.String);

            ICell cell1 = row.CreateCell(1);

            cell1.SetCellType(CellType.String);
            cell1.SetCellValue(entity.Xlc);

            ICell cell2 = row.CreateCell(2);

            cell2.SetCellType(CellType.String);
            cell2.SetCellValue(entity.Zy);

            ICell cell3 = row.CreateCell(3);

            cell3.SetCellType(CellType.String);
            cell3.SetCellValue(entity.Xs);
        }
Exemplo n.º 5
0
        private bool Save(Framework.Task.Task task, ref string errmsg)
        {
            bool result = true;

            YwTxjsService service = new YwTxjsService();
            YwTxjs        entity  = task.Entity as YwTxjs;

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

            if (entity.Did > 0)
            {
                baseDao.Update(entity);
            }
            else
            {
                YwTxjs temp = new YwTxjs();
                temp.Txm = entity.Txm;
                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);
        }
Exemplo n.º 6
0
        private bool Delete(Framework.Task.Task task, ref string errmsg)
        {
            YwTxjs delModel = new YwTxjs();

            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);
        }
Exemplo n.º 7
0
        private void DealRow(int rowIndex, IRow row)
        {
            YwTxjs temp = new YwTxjs();

            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.Txm = cell.StringCellValue.Trim();
                        if (temp.Txm == "")
                        {
                            throw new Exception("第" + rowIndex + "行    推修码 不能为空");
                        }
                    }
                    catch
                    {
                        throw new Exception("第" + rowIndex + "行    推修码 不能为空");
                    }
                    break;

                case 1:
                    try
                    {
                        if (cell.StringCellValue.Trim() == "")
                        {
                            temp.Xlc = "";
                        }
                        else
                        {
                            temp.Xlc = cell.StringCellValue.Trim();
                        }
                    }
                    catch
                    {
                        temp.Xlc = "";
                    }
                    break;

                case 2:
                    try
                    {
                        if (cell.StringCellValue.Trim() == "")
                        {
                            return;
                        }
                        temp.Zy = cell.StringCellValue.Trim();
                        if (temp.Zy == "")
                        {
                            throw new Exception("第" + rowIndex + "行   有无专员 不能为空");
                        }
                        else
                        {
                            if (temp.Zy != "有" && temp.Zy != "无")
                            {
                                throw new Exception("第" + rowIndex + "行   有无专员 不能为空");
                            }
                        }
                    }
                    catch
                    {
                        throw new Exception("第" + rowIndex + "行   有无专员 内容应该为 有 或者 无");
                    }
                    break;

                case 3:
                    decimal temp1 = 0;
                    try
                    {
                        temp1 = decimal.Parse(cell.StringCellValue.Trim());
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("第" + rowIndex + "行    推修系数值格式不正确,应该在0和100之间的数字");
                    }

                    temp.Xs = cell.StringCellValue.Trim();
                    break;
                }
            }
            if (this.CheckExist(temp.Txm) == true)
            {
                throw new Exception("第" + rowIndex + " 行  [" + temp.Txm + "]该推修码已经被定义");
            }
            baseDao.Insert(temp);
        }