Exemple #1
0
 public void InsertCustomer(AuthorizationDS.StuffUserRow stuffUser, AuthorizationDS.PositionRow position, string CustomerName, string CustomerNo, int CityID, int CustomerTypeID, int ChannelTypeID, int ApplyOrganizationUnitID, int OrganizationUnitID, Boolean IsActive)
 {
     if (ApplyOrganizationUnitID <= 0) {
         throw new ApplicationException("必须选择所属机构!");
     }
     if (OrganizationUnitID <= 0) {
         throw new ApplicationException("必须选择所属预算机构!");
     }
     // 检证"客户名称"唯一性
     int iCount = (int)this.CustomerAdapter.SearchNameByIns(CustomerName);
     if (iCount > 0) {
         throw new ApplicationException("客户名称不能重复!");
     }
     // 进行数据新增处理
     ERS.CustomerDataTable custItemTab = new ERS.CustomerDataTable();
     ERS.CustomerRow custRow = custItemTab.NewCustomerRow();
     // 进行传值
     custRow.CustomerName = CustomerName;
     custRow.CustomerNo = CustomerNo;
     custRow.CustomerTypeID = CustomerTypeID;
     custRow.CityID = CityID;
     custRow.ChannelTypeID = ChannelTypeID;
     custRow.OrganizationUnitID = OrganizationUnitID;
     custRow.ApplyOrganizationUnitID = ApplyOrganizationUnitID;
     custRow.IsActive = IsActive;
     // 填加行并进行更新处理
     custItemTab.AddCustomerRow(custRow);
     this.CustomerAdapter.Update(custItemTab);
     CommonDataEditAction action = new CommonDataEditAction();
     action.ActionTime = DateTime.Now;
     action.ActionType = "添加";
     action.DataTableName = "客户";
     action.NewValue = "客户名称:" + custRow.CustomerName;
     action.StuffId = stuffUser.StuffId;
     action.StuffName = stuffUser.StuffName;
     SysLog.LogCommonDataEditAction(action);
 }
Exemple #2
0
    public void SaveDataToDB(string FullPath, string FileName, string excelFileExtension)
    {
        SqlTransaction transaction = null;
        try {
            DataTable dt = null;
            dt = this.GetDataSet(FullPath, excelFileExtension).Tables[0];
            if (dt.Rows.Count <= 1) {
                PageUtility.ShowModelDlg(this.Page, "�ļ���û���κμ�¼��������ѡ��");
                return;
            }
            CustomerTableAdapter TACustomer = new CustomerTableAdapter();
            ImportLogTableAdapter TAImportLog = new ImportLogTableAdapter();
            ImportLogDetailTableAdapter TAImportLogDetail = new ImportLogDetailTableAdapter();
            MasterDataBLL mdBLL = new MasterDataBLL();

            transaction = TableAdapterHelper.BeginTransaction(TACustomer);
            TableAdapterHelper.SetTransaction(TAImportLog, transaction);
            TableAdapterHelper.SetTransaction(TAImportLogDetail, transaction);
            //�洢log��Ϣ
            ImportDS.ImportLogDataTable logTable = new ImportDS.ImportLogDataTable();
            ImportDS.ImportLogRow logRow = logTable.NewImportLogRow();

            int stuffUserID = ((AuthorizationDS.StuffUserRow)Session["StuffUser"]).StuffUserId;
            string fullname = this.fileUpLoad.PostedFile.FileName.ToString();
            string tmpFile = fullname.Remove(0, fullname.LastIndexOf("\\") + 1);
            logRow.FileName = tmpFile;
            logRow.ImportDate = DateTime.Now;
            logRow.ImportUserID = stuffUserID;
            logRow.ImportType = 3;
            logRow.TotalCount = dt.Rows.Count - 1;
            logRow.SuccessCount = dt.Rows.Count - 1;
            logRow.FailCount = 0;
            logTable.AddImportLogRow(logRow);
            TAImportLog.Update(logTable);

            //����ÿ����ϸ
            ERS.CustomerDataTable tbCustomer = new ERS.CustomerDataTable();
            ImportDS.ImportLogDetailDataTable ImportLogDetailTable = new ImportDS.ImportLogDetailDataTable();
            int row_count = dt.Rows.Count;
            string errorInfor = string.Empty;
            //  int expenseTypeID = int.Parse(ExpenseTypeDDL.SelectedValue);
            //��ʼ����ÿ����ϸ
            for (int i = 1; i <= row_count - 1; i++) {
                if (CheckData(dt.Rows[i]) != null) {
                    errorInfor = "��" + (i + 1) + "����" + CheckData(dt.Rows[i]);
                    ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                    ImportDetailRow.LogID = logRow.LogID;
                    ImportDetailRow.Line = i + 1;
                    ImportDetailRow.Error = errorInfor;
                    ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                    logRow.FailCount = logRow.FailCount + 1;
                    logRow.SuccessCount = logRow.SuccessCount - 1;
                    TAImportLog.Update(logRow);
                    continue;
                } else {
                    DataRow row = dt.Rows[i];
                    string CustomerNo = row[0].ToString().Trim();
                    string CustomerName = row[1].ToString().Trim();
                    string ProvinceName = row[2].ToString().Trim();
                    string CityName = row[3].ToString().Trim();
                    string CustomerTypeName = row[4].ToString().Trim();
                    string ChannelTypeName = row[5].ToString().Trim();
                    string OUName = row[6].ToString().Trim();
                    string BudgetOUName = row[7].ToString().Trim();

                    ERS.CustomerDataTable tbCustomerTemp = mdBLL.GetCustomerByCustomerName(CustomerName);

                    if (tbCustomerTemp != null && tbCustomerTemp.Count > 0) {
                        errorInfor = "��" + (i + 1) + "���д���Ѵ��ڿͻ���" + CustomerName + "��";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    //ERS.ProvinceDataTable tbProvince = mdBLL.GetProvinceByProvinceName(ProvinceName);

                    //if (tbProvince == null || tbProvince.Count == 0) {
                    //    errorInfor = "��" + (i + 1) + "���д���Ҳ���ʡ�ݡ�" + ProvinceName + "��";
                    //    ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                    //    ImportDetailRow.LogID = logRow.LogID;
                    //    ImportDetailRow.Line = i + 1;
                    //    ImportDetailRow.Error = errorInfor;
                    //    ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                    //    logRow.FailCount = logRow.FailCount + 1;
                    //    logRow.SuccessCount = logRow.SuccessCount - 1;
                    //    TAImportLog.Update(logRow);
                    //    continue;
                    //}

                    ERS.CityDataTable tbCity = mdBLL.GetCityByCityName(CityName);

                    if (tbCity == null || tbCity.Count == 0) {
                        errorInfor = "��" + (i + 1) + "���д���Ҳ������С�" + CityName + "��";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    ERS.CustomerTypeDataTable tbCustomerType = mdBLL.GetCustomerTypeByCustomerTypeName(CustomerTypeName);

                    if (tbCustomerType == null || tbCustomerType.Count == 0) {
                        errorInfor = "��" + (i + 1) + "���д���Ҳ����ͻ����͡�" + CustomerTypeName + "��";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    ERS.ChannelTypeDataTable tbChannelType = mdBLL.GetChannelTypeByChannelTypeName(ChannelTypeName);

                    if (tbChannelType == null || tbChannelType.Count == 0) {
                        errorInfor = "��" + (i + 1) + "���д���Ҳ����ͻ�������" + ChannelTypeName + "��";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    AuthorizationDS.OrganizationUnitDataTable ouTable = new OUTreeBLL().GetDataByOrganizationUnitName(OUName);

                    if (ouTable == null || ouTable.Count == 0) {
                        errorInfor = "��" + (i + 1) + "���д��ϵͳ���Ҳ����˲��š�" + OUName + "��";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    if (ouTable.Count > 1) {
                        errorInfor = "��" + (i + 1) + "���д��ϵͳ���ҵ���������ƵIJ��š�" + OUName + "��";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    AuthorizationDS.OrganizationUnitDataTable BudgetOUTable = new OUTreeBLL().GetDataByOrganizationUnitName(BudgetOUName);

                    if (BudgetOUTable == null || BudgetOUTable.Count == 0) {
                        errorInfor = "��" + (i + 1) + "���д��ϵͳ���Ҳ����˲��š�" + BudgetOUName + "��";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    if (BudgetOUTable.Count > 1) {
                        errorInfor = "��" + (i + 1) + "���д��ϵͳ���ҵ���������ƵIJ��š�" + BudgetOUName + "��";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    ERS.CustomerRow rowCustomer = tbCustomer.NewCustomerRow();

                    rowCustomer.CustomerNo = CustomerNo;
                    rowCustomer.CustomerName = CustomerName;
                    rowCustomer.CityID = tbCity[0].CityID;
                    rowCustomer.CustomerTypeID = tbCustomerType[0].CustomerTypeID;
                    rowCustomer.ChannelTypeID = tbChannelType[0].ChannelTypeID;
                    rowCustomer.OrganizationUnitID = ouTable[0].OrganizationUnitId;
                    rowCustomer.ApplyOrganizationUnitID = BudgetOUTable[0].OrganizationUnitId;
                    rowCustomer.IsActive = true;

                    tbCustomer.AddCustomerRow(rowCustomer);
                    TACustomer.Update(rowCustomer);
                }
            }
            TAImportLog.Update(logRow);
            TAImportLogDetail.Update(ImportLogDetailTable);
            transaction.Commit();
            string returnString = "�ɹ�����" + logRow.SuccessCount.ToString() + "����Ϣ";
            PageUtility.ShowModelDlg(this.Page, returnString);
        } catch (Exception ex) {
            if (transaction != null) {
                transaction.Rollback();
            } PageUtility.ShowModelDlg(this.Page, "Save Fail!" + ex.ToString());
        } finally {
            if (transaction != null) {
                transaction.Dispose();
            }
        }
    }
Exemple #3
0
    public void SaveDataToDB(string FullPath, string FileName, string excelFileExtension)
    {
        SqlTransaction transaction = null;

        try {
            DataTable dt = null;
            dt = this.GetDataSet(FullPath, excelFileExtension).Tables[0];
            if (dt.Rows.Count <= 1)
            {
                PageUtility.ShowModelDlg(this.Page, "文件中没有任何记录,请重新选择");
                return;
            }
            CustomerTableAdapter        TACustomer        = new CustomerTableAdapter();
            ImportLogTableAdapter       TAImportLog       = new ImportLogTableAdapter();
            ImportLogDetailTableAdapter TAImportLogDetail = new ImportLogDetailTableAdapter();
            MasterDataBLL mdBLL = new MasterDataBLL();

            transaction = TableAdapterHelper.BeginTransaction(TACustomer);
            TableAdapterHelper.SetTransaction(TAImportLog, transaction);
            TableAdapterHelper.SetTransaction(TAImportLogDetail, transaction);
            //存储log信息
            ImportDS.ImportLogDataTable logTable = new ImportDS.ImportLogDataTable();
            ImportDS.ImportLogRow       logRow   = logTable.NewImportLogRow();

            int    stuffUserID = ((AuthorizationDS.StuffUserRow)Session["StuffUser"]).StuffUserId;
            string fullname    = this.fileUpLoad.PostedFile.FileName.ToString();
            string tmpFile     = fullname.Remove(0, fullname.LastIndexOf("\\") + 1);
            logRow.FileName     = tmpFile;
            logRow.ImportDate   = DateTime.Now;
            logRow.ImportUserID = stuffUserID;
            logRow.ImportType   = 3;
            logRow.TotalCount   = dt.Rows.Count - 1;
            logRow.SuccessCount = dt.Rows.Count - 1;
            logRow.FailCount    = 0;
            logTable.AddImportLogRow(logRow);
            TAImportLog.Update(logTable);

            //处理每条明细
            ERS.CustomerDataTable             tbCustomer           = new ERS.CustomerDataTable();
            ImportDS.ImportLogDetailDataTable ImportLogDetailTable = new ImportDS.ImportLogDetailDataTable();
            int    row_count  = dt.Rows.Count;
            string errorInfor = string.Empty;
            //  int expenseTypeID = int.Parse(ExpenseTypeDDL.SelectedValue);
            //开始处理每条明细
            for (int i = 1; i <= row_count - 1; i++)
            {
                if (CheckData(dt.Rows[i]) != null)
                {
                    errorInfor = "第" + (i + 1) + "行有错:" + CheckData(dt.Rows[i]);
                    ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                    ImportDetailRow.LogID = logRow.LogID;
                    ImportDetailRow.Line  = i + 1;
                    ImportDetailRow.Error = errorInfor;
                    ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                    logRow.FailCount    = logRow.FailCount + 1;
                    logRow.SuccessCount = logRow.SuccessCount - 1;
                    TAImportLog.Update(logRow);
                    continue;
                }
                else
                {
                    DataRow row              = dt.Rows[i];
                    string  CustomerNo       = row[0].ToString().Trim();
                    string  CustomerName     = row[1].ToString().Trim();
                    string  ProvinceName     = row[2].ToString().Trim();
                    string  CityName         = row[3].ToString().Trim();
                    string  CustomerTypeName = row[4].ToString().Trim();
                    string  ChannelTypeName  = row[5].ToString().Trim();
                    string  OUName           = row[6].ToString().Trim();
                    string  BudgetOUName     = row[7].ToString().Trim();

                    ERS.CustomerDataTable tbCustomerTemp = mdBLL.GetCustomerByCustomerName(CustomerName);

                    if (tbCustomerTemp != null && tbCustomerTemp.Count > 0)
                    {
                        errorInfor = "第" + (i + 1) + "行有错:已存在客户《" + CustomerName + "》";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line  = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount    = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    //ERS.ProvinceDataTable tbProvince = mdBLL.GetProvinceByProvinceName(ProvinceName);

                    //if (tbProvince == null || tbProvince.Count == 0) {
                    //    errorInfor = "第" + (i + 1) + "行有错:找不到省份《" + ProvinceName + "》";
                    //    ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                    //    ImportDetailRow.LogID = logRow.LogID;
                    //    ImportDetailRow.Line = i + 1;
                    //    ImportDetailRow.Error = errorInfor;
                    //    ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                    //    logRow.FailCount = logRow.FailCount + 1;
                    //    logRow.SuccessCount = logRow.SuccessCount - 1;
                    //    TAImportLog.Update(logRow);
                    //    continue;
                    //}

                    ERS.CityDataTable tbCity = mdBLL.GetCityByCityName(CityName);

                    if (tbCity == null || tbCity.Count == 0)
                    {
                        errorInfor = "第" + (i + 1) + "行有错:找不到城市《" + CityName + "》";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line  = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount    = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    ERS.CustomerTypeDataTable tbCustomerType = mdBLL.GetCustomerTypeByCustomerTypeName(CustomerTypeName);

                    if (tbCustomerType == null || tbCustomerType.Count == 0)
                    {
                        errorInfor = "第" + (i + 1) + "行有错:找不到客户类型《" + CustomerTypeName + "》";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line  = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount    = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    ERS.ChannelTypeDataTable tbChannelType = mdBLL.GetChannelTypeByChannelTypeName(ChannelTypeName);

                    if (tbChannelType == null || tbChannelType.Count == 0)
                    {
                        errorInfor = "第" + (i + 1) + "行有错:找不到客户渠道《" + ChannelTypeName + "》";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line  = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount    = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    AuthorizationDS.OrganizationUnitDataTable ouTable = new OUTreeBLL().GetDataByOrganizationUnitName(OUName);

                    if (ouTable == null || ouTable.Count == 0)
                    {
                        errorInfor = "第" + (i + 1) + "行有错:系统中找不到此部门《" + OUName + "》";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line  = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount    = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    if (ouTable.Count > 1)
                    {
                        errorInfor = "第" + (i + 1) + "行有错:系统中找到多个此名称的部门《" + OUName + "》";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line  = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount    = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    AuthorizationDS.OrganizationUnitDataTable BudgetOUTable = new OUTreeBLL().GetDataByOrganizationUnitName(BudgetOUName);

                    if (BudgetOUTable == null || BudgetOUTable.Count == 0)
                    {
                        errorInfor = "第" + (i + 1) + "行有错:系统中找不到此部门《" + BudgetOUName + "》";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line  = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount    = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    if (BudgetOUTable.Count > 1)
                    {
                        errorInfor = "第" + (i + 1) + "行有错:系统中找到多个此名称的部门《" + BudgetOUName + "》";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line  = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount    = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    ERS.CustomerRow rowCustomer = tbCustomer.NewCustomerRow();

                    rowCustomer.CustomerNo              = CustomerNo;
                    rowCustomer.CustomerName            = CustomerName;
                    rowCustomer.CityID                  = tbCity[0].CityID;
                    rowCustomer.CustomerTypeID          = tbCustomerType[0].CustomerTypeID;
                    rowCustomer.ChannelTypeID           = tbChannelType[0].ChannelTypeID;
                    rowCustomer.OrganizationUnitID      = ouTable[0].OrganizationUnitId;
                    rowCustomer.ApplyOrganizationUnitID = BudgetOUTable[0].OrganizationUnitId;
                    rowCustomer.IsActive                = true;

                    tbCustomer.AddCustomerRow(rowCustomer);
                    TACustomer.Update(rowCustomer);
                }
            }
            TAImportLog.Update(logRow);
            TAImportLogDetail.Update(ImportLogDetailTable);
            transaction.Commit();
            string returnString = "成功导入" + logRow.SuccessCount.ToString() + "条信息";
            PageUtility.ShowModelDlg(this.Page, returnString);
        } catch (Exception ex) {
            if (transaction != null)
            {
                transaction.Rollback();
            }
            PageUtility.ShowModelDlg(this.Page, "Save Fail!" + ex.ToString());
        } finally {
            if (transaction != null)
            {
                transaction.Dispose();
            }
        }
    }