Esempio n. 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_HYXX", dt, true, true);
        T_BM_HYXXApplicationLogic instanceT_BM_HYXXApplicationLogic = (T_BM_HYXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_HYXXApplicationLogic));

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

            appData.HYBH = instanceT_BM_HYXXApplicationLogic.AutoGenerateHYBH(appData);

            int i = 0;

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

            // 验证输入参数

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

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

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

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

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

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

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

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

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

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

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

            // 自动生成编号
            T_BM_HYXXApplicationLogic instanceT_BM_HYXXApplicationLogic
                = (T_BM_HYXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_HYXXApplicationLogic));

            appData.HYBH = instanceT_BM_HYXXApplicationLogic.AutoGenerateHYBH(appData);

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

        try
        {
            var appDatas = T_BM_HYXXApplicationData.GetDataFromDataFile <T_BM_HYXXApplicationData>(InfoFromDoc.Text, true, true, recordStartLine: T_BM_HYXXContants.ImportDataSetStartLineNum);
            T_BM_HYXXApplicationLogic instanceT_BM_HYXXApplicationLogic = (T_BM_HYXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_HYXXApplicationLogic));
            totalCount = appDatas.Count;
            foreach (var app in appDatas)
            {
                app.HYBH = instanceT_BM_HYXXApplicationLogic.AutoGenerateHYBH(app);

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

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

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

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

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

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

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

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

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

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

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

                instanceT_BM_HYXXApplicationLogic.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_HYXXApplicationLogic.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);
        }
    }