Example #1
0
    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_BM_KCYYXX", dt, true, true);
        T_BM_KCYYXXApplicationLogic instanceT_BM_KCYYXXApplicationLogic = (T_BM_KCYYXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_KCYYXXApplicationLogic));

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

            appData.KCYYBH = instanceT_BM_KCYYXXApplicationLogic.AutoGenerateKCYYBH(appData);

            int i = 0;

            appData = instanceT_BM_KCYYXXApplicationLogic.Add(appData);
        }
    }
        //=====================================================================
        //  FunctionName : GetAddInputParameter
        /// <summary>
        /// 得到添加用户输入参数操作
        /// </summary>
        //=====================================================================
        protected override Boolean GetAddInputParameter()
        {
            Boolean      boolReturn   = true;
            ValidateData validateData = new ValidateData();

            // 验证输入参数

            validateData = ValidateKCBBH(KCBBH.SelectedValue, false, false);
            if (validateData.Result)
            {
                if (!validateData.IsNull)
                {
                    appData.KCBBH = Convert.ToString(validateData.Value.ToString());
                }
                KCBBH.BackColor = System.Drawing.Color.Empty;
            }
            else
            {
                KCBBH.BackColor = System.Drawing.Color.YellowGreen;
                MessageContent += @"<font color=""red"">" + validateData.Message + "</font>";
                boolReturn      = validateData.Result;
            }

            validateData = ValidateHYBH(HYBH.SelectedValue, false, false);
            if (validateData.Result)
            {
                if (!validateData.IsNull)
                {
                    appData.HYBH = Convert.ToString(validateData.Value.ToString());
                }
                HYBH.BackColor = System.Drawing.Color.Empty;
            }
            else
            {
                HYBH.BackColor  = System.Drawing.Color.YellowGreen;
                MessageContent += @"<font color=""red"">" + validateData.Message + "</font>";
                boolReturn      = validateData.Result;
            }

            validateData = ValidateYYSJ(YYSJ.Text, false, false);
            if (validateData.Result)
            {
                if (!validateData.IsNull)
                {
                    appData.YYSJ = Convert.ToDateTime(validateData.Value.ToString());
                }
                YYSJ.BackColor = System.Drawing.Color.Empty;
            }
            else
            {
                YYSJ.BackColor  = System.Drawing.Color.YellowGreen;
                MessageContent += @"<font color=""red"">" + validateData.Message + "</font>";
                boolReturn      = validateData.Result;
            }

            validateData = ValidateYYBZ(YYBZ.Text, true, false);
            if (validateData.Result)
            {
                if (!validateData.IsNull)
                {
                    appData.YYBZ = Convert.ToString(validateData.Value.ToString());
                }
                YYBZ.BackColor = System.Drawing.Color.Empty;
            }
            else
            {
                YYBZ.BackColor  = System.Drawing.Color.YellowGreen;
                MessageContent += @"<font color=""red"">" + validateData.Message + "</font>";
                boolReturn      = validateData.Result;
            }

            validateData = ValidateSKZT(SKZT.Text, true, false);
            if (validateData.Result)
            {
                if (!validateData.IsNull)
                {
                    appData.SKZT = Convert.ToString(validateData.Value.ToString());
                }
                SKZT.BackColor = System.Drawing.Color.Empty;
            }
            else
            {
                SKZT.BackColor  = System.Drawing.Color.YellowGreen;
                MessageContent += @"<font color=""red"">" + validateData.Message + "</font>";
                boolReturn      = validateData.Result;
            }

            validateData = ValidateXHKS(XHKS.Text, true, false);
            if (validateData.Result)
            {
                if (!validateData.IsNull)
                {
                    appData.XHKS = Convert.ToInt32(validateData.Value.ToString());
                }
                XHKS.BackColor = System.Drawing.Color.Empty;
            }
            else
            {
                XHKS.BackColor  = System.Drawing.Color.YellowGreen;
                MessageContent += @"<font color=""red"">" + validateData.Message + "</font>";
                boolReturn      = validateData.Result;
            }

            if (KTZP.Upload())
            {
                appData.KTZP = KTZP.Text;
            }
            else
            {
                MessageContent += @"<font color=""red"">" + KTZP.Message + "</font>";
                boolReturn      = false;
            }

            validateData = ValidateJSPJ(JSPJ.Text, true, false);
            if (validateData.Result)
            {
                if (!validateData.IsNull)
                {
                    appData.JSPJ = Convert.ToString(validateData.Value.ToString());
                }
                JSPJ.BackColor = System.Drawing.Color.Empty;
            }
            else
            {
                JSPJ.BackColor  = System.Drawing.Color.YellowGreen;
                MessageContent += @"<font color=""red"">" + validateData.Message + "</font>";
                boolReturn      = validateData.Result;
            }

            validateData = ValidatePJR(PJR.Text, true, false);
            if (validateData.Result)
            {
                if (!validateData.IsNull)
                {
                    appData.PJR = Convert.ToString(validateData.Value.ToString());
                }
                PJR.BackColor = System.Drawing.Color.Empty;
            }
            else
            {
                PJR.BackColor   = System.Drawing.Color.YellowGreen;
                MessageContent += @"<font color=""red"">" + validateData.Message + "</font>";
                boolReturn      = validateData.Result;
            }

            validateData = ValidatePJSJ(PJSJ.Text, true, false);
            if (validateData.Result)
            {
                if (!validateData.IsNull)
                {
                    appData.PJSJ = Convert.ToDateTime(validateData.Value.ToString());
                }
                PJSJ.BackColor = System.Drawing.Color.Empty;
            }
            else
            {
                PJSJ.BackColor  = System.Drawing.Color.YellowGreen;
                MessageContent += @"<font color=""red"">" + validateData.Message + "</font>";
                boolReturn      = validateData.Result;
            }

            // 自动生成编号
            T_BM_KCYYXXApplicationLogic instanceT_BM_KCYYXXApplicationLogic
                = (T_BM_KCYYXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_KCYYXXApplicationLogic));

            appData.KCYYBH = instanceT_BM_KCYYXXApplicationLogic.AutoGenerateKCYYBH(appData);

            return(boolReturn);
        }
Example #3
0
    protected void btnInfoFromDS_Click(object sender, EventArgs e)
    {
        int totalCount  = 0;
        int importCount = 0;
        int updateCount = 0;

        try
        {
            var appDatas = T_BM_KCYYXXApplicationData.GetDataFromDataFile <T_BM_KCYYXXApplicationData>(InfoFromDoc.Text, true, true, recordStartLine: T_BM_KCYYXXContants.ImportDataSetStartLineNum);
            T_BM_KCYYXXApplicationLogic instanceT_BM_KCYYXXApplicationLogic = (T_BM_KCYYXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_KCYYXXApplicationLogic));
            totalCount = appDatas.Count;
            foreach (var app in appDatas)
            {
                app.KCYYBH = instanceT_BM_KCYYXXApplicationLogic.AutoGenerateKCYYBH(app);

                string strKCBBH = GetValue(new RICH.Common.BM.T_BM_KCBXX.T_BM_KCBXXApplicationLogicBase().GetValueByFixCondition("KCBH", app.KCBBH, "KCBBH"));
                if (!DataValidateManager.ValidateIsNull(strKCBBH))
                {
                    app.KCBBH = strKCBBH;
                }
                if (!KCBBH.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.KCBBH = Convert.ToString(KCBBH.SelectedValue);
                }

                string strHYBH = GetValue(new RICH.Common.BM.T_BM_HYXX.T_BM_HYXXApplicationLogicBase().GetValueByFixCondition("HYXM", app.HYBH, "HYBH"));
                if (!DataValidateManager.ValidateIsNull(strHYBH))
                {
                    app.HYBH = strHYBH;
                }
                if (!HYBH.SelectedValue.IsHtmlNullOrWiteSpace())
                {
                    app.HYBH = Convert.ToString(HYBH.SelectedValue);
                }

                if (!YYSJ.Text.IsHtmlNullOrWiteSpace())
                {
                    app.YYSJ = Convert.ToDateTime(YYSJ.Text);
                }

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

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

                if (!XHKS.Text.IsHtmlNullOrWiteSpace())
                {
                    app.XHKS = Convert.ToInt32(XHKS.Text);
                }

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

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

                string strPJR = GetValue(new RICH.Common.BM.T_PM_UserInfo.T_PM_UserInfoApplicationLogicBase().GetValueByFixCondition("UserNickName", app.PJR, "UserID"));
                if (!DataValidateManager.ValidateIsNull(strPJR))
                {
                    app.PJR = strPJR;
                }
                if (!PJR.Text.IsHtmlNullOrWiteSpace())
                {
                    app.PJR = Convert.ToString(PJR.Text);
                }

                if (!PJSJ.Text.IsHtmlNullOrWiteSpace())
                {
                    app.PJSJ = Convert.ToDateTime(PJSJ.Text);
                }

                instanceT_BM_KCYYXXApplicationLogic.Add(app);
                if (app.ResultCode == RICH.Common.Base.ApplicationData.ApplicationDataBase.ResultState.Succeed)
                {
                    importCount++;
                }
                else
                {
                    app.OPCode = RICH.Common.Base.ApplicationData.ApplicationDataBase.OPType.PK;
                    instanceT_BM_KCYYXXApplicationLogic.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);
        }
    }