Exemple #1
0
        protected override bool CheckDataRow(DataRow dr, ErrorItem item, string[] keyValue)
        {
            string taskType = keyValue[1];

            for (int i = 0; i < dr.ItemArray.Length; i++)
            {
                if (i == 0)
                {
                    if (taskType.Equals("0"))
                    {
                        //分公司
                        string branchName = dr.ItemArray[0] + "";
                        if (string.IsNullOrEmpty(branchName))
                        {
                            item.ErrorReson = "分公司名称不能为空";
                            return(false);
                        }
                        if (organizeApp.GetOrgByName(branchName) == null)
                        {
                            item.ErrorReson = "“" + branchName + "”不存在";
                            return(false);
                        }
                    }
                    else
                    {
                        try
                        {
                            // 个人
                            string userName  = dr.ItemArray[0] + "";
                            string userPhone = dr.ItemArray[14] + "";

                            if (string.IsNullOrEmpty(userName))
                            {
                                item.ErrorReson = "员工姓名不能为空";
                                return(false);
                            }
                            if (string.IsNullOrEmpty(userPhone))
                            {
                                item.ErrorReson = "员工电话号码不能为空";
                                return(false);
                            }
                            if (userApp.GetByPhone(userPhone) == null)
                            {
                                item.ErrorReson = "“" + userName + "”(phone:" + userPhone + ")不存在";
                                return(false);
                            }
                        }
                        catch
                        {
                            item.ErrorReson = "请下载使用最新正确的【个人】全年任务指标数据录入模板!";
                            return(false);
                        }
                    }
                }
                else
                {
                    string value = dr.ItemArray[i] + "";
                    if (string.IsNullOrEmpty(value))
                    {
                        item.ErrorReson = "完成量不能为空";
                        return(false);
                    }
                    if (!Validate.IsNumber(value))
                    {
                        item.ErrorReson = "指标量必须是数字";
                        return(false);
                    }
                }
            }
            return(true);
        }