Exemplo n.º 1
0
        protected bool CheckData(List<Archive> list , out BatchImportResult result )
        {
            result = new BatchImportResult();
            if (list == null) return true;

            result.ErrorList = new List<BatchImportResult.ExcelErrorLine>();
            bool isok = true;
            for (int i = 0; i < list.Count; i++)
            {
                string msg = "";

                if (string.IsNullOrEmpty(list[i].manager))
                {
                    isok = false;
                    msg += "负责人不能空";
                }

                if (string.IsNullOrEmpty(list[i].title))
                {
                    isok = false;
                    msg += "文件题名不能空";
                }

                if (string.IsNullOrEmpty(list[i].number))
                {
                    isok = false;
                    if (msg != "")
                    {
                        msg += ",";
                    }
                    msg += "编号不能空";
                }
                

                if ( msg !="")
                {
                    result.ErrorList.Add(new BatchImportResult.ExcelErrorLine((i + 2).ToString(), msg ));
                }
            }
            return isok;

        }
Exemplo n.º 2
0
        protected bool CheckData(List<Contract> list , out BatchImportResult result )
        {
            result = new BatchImportResult();
            if (list == null) return true;

            result.ErrorList = new List<BatchImportResult.ExcelErrorLine>();
            bool isok = true;
            for (int i = 0; i < list.Count; i++)
            {
                string msg = "";
                if (string.IsNullOrEmpty(list[i].contractnum))
                {
                    isok = false;
                    msg += "合同编号不能空";
                }

                if (string.IsNullOrEmpty(list[i].seq))
                {
                    isok = false;
                    if (msg != "")
                    {
                        msg += ",";
                    }
                    msg += "序号不能空";
                }

                if (string.IsNullOrEmpty(list[i].projectnum) || string.IsNullOrEmpty(list[i].projectname))
                {
                    isok = false;
                    if (msg != "")
                    {
                        msg += ",";
                    }
                    msg += "项目编号和项目名称不能空";
                }
                if (string.IsNullOrEmpty(list[i].packageBudget) == false)
                {
                    decimal fbys = 0;
                    if (decimal.TryParse(list[i].packageBudget, out fbys) == false)
                    {
                        isok = false;
                        if (msg != "")
                        {
                            msg += ",";
                        }
                        msg += "分包预算必须是数字";
                    }
                }
                else
                {
                    list[i].packageBudget = "0.00";
                }

                if (string.IsNullOrEmpty(list[i].money) == false)
                {
                    decimal zbje = 0;
                    if (decimal.TryParse(list[i].money, out zbje) == false)
                    {
                        isok = false;
                        if (msg != "")
                        {
                            msg += ",";
                        }
                        msg += "中标金额必须是数字";
                    }
                }
                else
                {
                    list[i].money = "0.00";
                }

                if ( msg !="")
                {
                    result.ErrorList.Add(new BatchImportResult.ExcelErrorLine((i + 2).ToString(), msg ));
                }
            }
            return isok;

        }
Exemplo n.º 3
0
        public Beans.BatchImportResult BatchAddArchives(List<Archive> list , int startLine , string operatorName )
        {
            Beans.BatchImportResult result = null;

            if (list == null || list.Count < 1) return result;

            if (CheckData(list , out result ) == false) return result;

            result = new BatchImportResult();
            result.TotalCount = list.Count;               

            int addcount  =0;  
            int updatecount = 0;
            int fail = 0;
            List<Beans.BatchImportResult.ExcelErrorLine> errLines = new List<BatchImportResult.ExcelErrorLine>();
            int idx = startLine;//1; //因为excel 从第二行开始数据行
            foreach (Archive c in list)
            {           
                idx ++;
                bool isExist = ExistArchive(c.manager, c.title, c.number);
                if (isExist)
                {
                    //bool isSuccess = EditContractByProjectNumAndSeq(c); // EditContractByProjectNumAndProjectName(c);
                    //updatecount += isSuccess ? 1 : 0;
                    //fail += isSuccess ? 0 : 1;   
                    fail++;
                    errLines.Add( new BatchImportResult.ExcelErrorLine( idx.ToString() , "数据重复"));
                }
                else
                {
                    c.operateman = operatorName;
                    bool isSuccess = AddArchive(c);
                    addcount += isSuccess ? 1 : 0;
                    fail += isSuccess ? 0 : 1;
                    if (isSuccess == false ) errLines.Add( new BatchImportResult.ExcelErrorLine( idx .ToString () , "新增失败"));
                }
            }

            result.AddCount = addcount;
            result.UpdateCount = updatecount;
            result.FailureCount = fail;
            result.ErrorList = errLines;

            return result;
        }
Exemplo n.º 4
0
        public Beans.BatchImportResult BatchAddContracts(List<Contract> list , string operatorName )
        {
            Beans.BatchImportResult result = null;

            if (list == null || list.Count < 1) return result;

            if (CheckData(list , out result ) == false) return result;

            result = new BatchImportResult();
            result.TotalCount = list.Count;               

            int addcount  =0;  
            int updatecount = 0;
            int fail = 0;
            List<Beans.BatchImportResult.ExcelErrorLine> errLines = new List<BatchImportResult.ExcelErrorLine>();
            int idx = 1; //因为excel 从第二行开始数据行
            foreach (Contract c in list)
            {           
                idx ++;
                bool isExist = ExistContractBySeqAndprojectNum ( c.seq , c.projectnum );
                if (isExist)
                {
                    bool isSuccess = EditContractByProjectNumAndSeq(c); // EditContractByProjectNumAndProjectName(c);
                    updatecount += isSuccess ? 1 : 0;
                    fail += isSuccess ? 0 : 1;   
                    if( isSuccess == false ) errLines.Add( new BatchImportResult.ExcelErrorLine( idx.ToString() , "更新失败"));
                }
                else
                {
                    c.operatorName = operatorName;
                    bool isSuccess = AddContract(c);
                    addcount += isSuccess ? 1 : 0;
                    fail += isSuccess ? 0 : 1;
                    if (isSuccess == false ) errLines.Add( new BatchImportResult.ExcelErrorLine( idx .ToString () , "新增失败"));
                }
            }

            result.AddCount = addcount;
            result.UpdateCount = updatecount;
            result.FailureCount = fail;

            return result;
        }