Beispiel #1
0
    //=====================================================================
    //  FunctionName : AddRecord
    /// <summary>
    /// 添加记录操作
    /// </summary>
    //=====================================================================
    protected override void AddRecord()
    {
        if (GetAddInputParameter())
        {
            T_PM_UserInfoApplicationLogic instanceT_PM_UserInfoApplicationLogic
                = (T_PM_UserInfoApplicationLogic)CreateApplicationLogicInstance(typeof(T_PM_UserInfoApplicationLogic));
            // 添加主表
            appData = instanceT_PM_UserInfoApplicationLogic.Add(appData);
            // 批量添加相关表
            RelatedTableAddBatch();
            if (appData.ResultCode == ApplicationDataBase.ResultState.Succeed)
            {
                // 对成功消息进行处理
                strMessageParam[0] = "用户信息";
                strMessageParam[1] = "添加";
                strMessageInfo     = MessageManager.GetMessageInfo(MessageManager.HINT_MSGID_0015, strMessageParam, strMessageInfo);
                MessageContent     = strMessageInfo;

                // 记录日志开始
                string strLogTypeID = "A02";
                strMessageParam[0] = (string)Session[ConstantsManager.SESSION_USER_LOGIN_NAME];
                strMessageParam[1] = "用户信息";
                strMessageParam[2] = appData.UserLoginName.ToString();
                strMessageParam[3] = "添加";
                string strLogContent = MessageManager.GetMessageInfo(MessageManager.LOG_MSGID_0003, strMessageParam);
                LogLibrary.LogWrite(strLogTypeID, strLogContent, null, null, null);
                // 记录日志结束

                // 发送Email
                SendValidateMail(appData.UserLoginName, appData.UserNickName, DomainUrl, appData.vcode);

                // 成功后页面跳转
                Page.CloseWindow(true);
            }
            else
            {
                // 对失败消息进行处理
                strMessageParam[0] = "此编号";
                strMessageParam[1] = "用户信息";
                strMessageInfo     = MessageManager.GetMessageInfo(MessageManager.ERR_MSGID_0013, strMessageParam, strMessageInfo);
                MessageContent     = strMessageInfo;
                Session[ConstantsManager.SESSION_MESSAGE_TYPE] = "FaildPre";
            }
        }
    }
    protected void btnInfoFromDocBatch_Click(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();

        dt = GetTemplateColumn(dt);
        dt = FileLibrary.GetDataFromWordBatch(ConstantsManager.WEBSITE_VIRTUAL_ROOT_DIR + "/" + ConstantsManager.UPLOAD_DOC_DIR + "/" + "T_PM_UserInfo", dt, true, true);
        T_PM_UserInfoApplicationLogic instanceT_PM_UserInfoApplicationLogic = (T_PM_UserInfoApplicationLogic)CreateApplicationLogicInstance(typeof(T_PM_UserInfoApplicationLogic));

        foreach (DataRow dr in dt.Rows)
        {
            appData = new T_PM_UserInfoApplicationData();

            appData.UserID = instanceT_PM_UserInfoApplicationLogic.AutoGenerateUserID(appData);

            int i = 0;

            appData = instanceT_PM_UserInfoApplicationLogic.Add(appData);
        }
    }
    protected void btnInfoFromDS_Click(object sender, EventArgs e)
    {
        int totalCount  = 0;
        int importCount = 0;
        int updateCount = 0;

        try
        {
            var appDatas = T_PM_UserInfoApplicationData.GetDataFromDataFile <T_PM_UserInfoApplicationData>(InfoFromDoc.Text, true, true, recordStartLine: T_PM_UserInfoContants.ImportDataSetStartLineNum);
            T_PM_UserInfoApplicationLogic instanceT_PM_UserInfoApplicationLogic = (T_PM_UserInfoApplicationLogic)CreateApplicationLogicInstance(typeof(T_PM_UserInfoApplicationLogic));
            totalCount = appDatas.Count;
            foreach (var app in appDatas)
            {
                app.UserID = instanceT_PM_UserInfoApplicationLogic.AutoGenerateUserID(app);

                if (!UserLoginName.Text.IsHtmlNullOrWiteSpace())
                {
                    app.UserLoginName = Convert.ToString(UserLoginName.Text);
                }

                string strUserGroupID = GetValue(new RICH.Common.BM.T_PM_UserGroupInfo.T_PM_UserGroupInfoApplicationLogicBase().GetValueByFixCondition("UserGroupName", app.UserGroupID, "UserGroupID"));
                if (!DataValidateManager.ValidateIsNull(strUserGroupID))
                {
                    app.UserGroupID = strUserGroupID;
                }
                if (!UserGroupID.SelectedValues.IsHtmlNullOrWiteSpace())
                {
                    app.UserGroupID = Convert.ToString(UserGroupID.SelectedValues);
                }

                string strSubjectID = GetValue(new RICH.Common.BM.T_BM_DWXX.T_BM_DWXXApplicationLogicBase().GetValueByFixCondition("DWMC", app.SubjectID, "DWBH"));
                if (!DataValidateManager.ValidateIsNull(strSubjectID))
                {
                    app.SubjectID = strSubjectID;
                }
                if (!SubjectID.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.SubjectID = Convert.ToString(SubjectID.SelectedValue);
                }

                if (!UserNickName.Text.IsHtmlNullOrWiteSpace())
                {
                    app.UserNickName = Convert.ToString(UserNickName.Text);
                }

                if (!Password.Text.IsHtmlNullOrWiteSpace())
                {
                    app.Password = Convert.ToString(Password.Text);
                }

                string strXB = GetValue(new RICH.Common.BM.Dictionary.DictionaryApplicationLogicBase().GetValueByFixCondition("MC", app.XB, "DM"));
                if (!DataValidateManager.ValidateIsNull(strXB))
                {
                    app.XB = strXB;
                }
                if (!XB.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.XB = Convert.ToString(XB.SelectedValue);
                }

                string strMZ = GetValue(new RICH.Common.BM.Dictionary.DictionaryApplicationLogicBase().GetValueByFixCondition("MC", app.MZ, "DM"));
                if (!DataValidateManager.ValidateIsNull(strMZ))
                {
                    app.MZ = strMZ;
                }
                if (!MZ.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.MZ = Convert.ToString(MZ.SelectedValue);
                }

                string strZZMM = GetValue(new RICH.Common.BM.Dictionary.DictionaryApplicationLogicBase().GetValueByFixCondition("MC", app.ZZMM, "DM"));
                if (!DataValidateManager.ValidateIsNull(strZZMM))
                {
                    app.ZZMM = strZZMM;
                }
                if (!ZZMM.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.ZZMM = Convert.ToString(ZZMM.SelectedValue);
                }

                if (!SFZH.Text.IsHtmlNullOrWiteSpace())
                {
                    app.SFZH = Convert.ToString(SFZH.Text);
                }

                if (!SJH.Text.IsHtmlNullOrWiteSpace())
                {
                    app.SJH = Convert.ToString(SJH.Text);
                }

                if (!BGDH.Text.IsHtmlNullOrWiteSpace())
                {
                    app.BGDH = Convert.ToString(BGDH.Text);
                }

                if (!JTDH.Text.IsHtmlNullOrWiteSpace())
                {
                    app.JTDH = Convert.ToString(JTDH.Text);
                }

                if (!Email.Text.IsHtmlNullOrWiteSpace())
                {
                    app.Email = Convert.ToString(Email.Text);
                }

                if (!QQH.Text.IsHtmlNullOrWiteSpace())
                {
                    app.QQH = Convert.ToString(QQH.Text);
                }

                string strUserStatus = GetValue(new RICH.Common.BM.Dictionary.DictionaryApplicationLogicBase().GetValueByFixCondition("MC", app.UserStatus, "DM"));
                if (!DataValidateManager.ValidateIsNull(strUserStatus))
                {
                    app.UserStatus = strUserStatus;
                }
                if (!UserStatus.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.UserStatus = Convert.ToString(UserStatus.SelectedValue);
                }

                if (!vcode.Text.IsHtmlNullOrWiteSpace())
                {
                    app.vcode = Convert.ToString(vcode.Text);
                }

                instanceT_PM_UserInfoApplicationLogic.Add(app);
                if (app.ResultCode == RICH.Common.Base.ApplicationData.ApplicationDataBase.ResultState.Succeed)
                {
                    importCount++;
                }
                else
                {
                    app.OPCode = RICH.Common.Base.ApplicationData.ApplicationDataBase.OPType.PK;
                    instanceT_PM_UserInfoApplicationLogic.Modify(app);
                    if (app.ResultCode == RICH.Common.Base.ApplicationData.ApplicationDataBase.ResultState.Succeed)
                    {
                        updateCount++;
                    }
                }
            }
            MessageContent += @"<font color=""green"">共{0}条数据,导入数据{1}条,更新数据{2}条。</font>".FormatInvariantCulture(totalCount, importCount, updateCount);
        }
        catch (Exception ex)
        {
            MessageContent += @"<font color=""red"">导入数据过程出错:{0}<br/>共{1}条数据,已导入数据{2}条,已更新数据{3}条。</font>".FormatInvariantCulture(ex.Message, totalCount, importCount, updateCount);
        }
    }