コード例 #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtMapCode.Text.Trim().Length == 0)
            {
                strErr += "MapCode不能为空!\\n";
            }
            if (this.txtStormSystem_ID.Text.Trim().Length == 0)
            {
                strErr += "StormSystem_ID不能为空!\\n";
            }
            if (this.txtType.Text.Trim().Length == 0)
            {
                strErr += "Type不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtX.Text))
            {
                strErr += "X格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtY.Text))
            {
                strErr += "Y格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtHigh.Text))
            {
                strErr += "High格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtWellDeep.Text))
            {
                strErr += "WellDeep格式错误!\\n";
            }
            if (this.txtOffset.Text.Trim().Length == 0)
            {
                strErr += "Offset不能为空!\\n";
            }
            if (this.txtFeature.Text.Trim().Length == 0)
            {
                strErr += "Feature不能为空!\\n";
            }
            if (this.txtSubsid.Text.Trim().Length == 0)
            {
                strErr += "Subsid不能为空!\\n";
            }
            if (this.txtModel.Text.Trim().Length == 0)
            {
                strErr += "Model不能为空!\\n";
            }
            if (this.txtWellPipes.Text.Trim().Length == 0)
            {
                strErr += "WellPipes不能为空!\\n";
            }
            if (this.txtWellShape.Text.Trim().Length == 0)
            {
                strErr += "WellShape不能为空!\\n";
            }
            if (this.txtWellSize.Text.Trim().Length == 0)
            {
                strErr += "WellSize不能为空!\\n";
            }
            if (this.txtWellMaterial.Text.Trim().Length == 0)
            {
                strErr += "WellMaterial不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtWaterDeep.Text))
            {
                strErr += "WaterDeep格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtMudDeep.Text))
            {
                strErr += "MudDeep格式错误!\\n";
            }
            if (this.txtInlet_Type.Text.Trim().Length == 0)
            {
                strErr += "Inlet_Type不能为空!\\n";
            }
            if (this.txtOutfallType.Text.Trim().Length == 0)
            {
                strErr += "OutfallType不能为空!\\n";
            }
            if (this.txtReceiveWater.Text.Trim().Length == 0)
            {
                strErr += "ReceiveWater不能为空!\\n";
            }
            if (this.txtFlap.Text.Trim().Length == 0)
            {
                strErr += "Flap不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtFlap_Diameter.Text))
            {
                strErr += "Flap_Diameter格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtFlap_TopEle.Text))
            {
                strErr += "Flap_TopEle格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtFlap_BotEle.Text))
            {
                strErr += "Flap_BotEle格式错误!\\n";
            }
            if (this.txtFlap_Material.Text.Trim().Length == 0)
            {
                strErr += "Flap_Material不能为空!\\n";
            }
            if (this.txtAddress.Text.Trim().Length == 0)
            {
                strErr += "Address不能为空!\\n";
            }
            if (this.txtPointPosition.Text.Trim().Length == 0)
            {
                strErr += "PointPosition不能为空!\\n";
            }
            if (this.txtDataSource.Text.Trim().Length == 0)
            {
                strErr += "DataSource不能为空!\\n";
            }
            if (this.txtVisibility.Text.Trim().Length == 0)
            {
                strErr += "Visibility不能为空!\\n";
            }
            if (this.txtSdate.Text.Trim().Length == 0)
            {
                strErr += "Sdate不能为空!\\n";
            }
            if (this.txtMdate.Text.Trim().Length == 0)
            {
                strErr += "Mdate不能为空!\\n";
            }
            if (this.txtManhole_Type.Text.Trim().Length == 0)
            {
                strErr += "Manhole_Type不能为空!\\n";
            }
            if (this.txtstatus.Text.Trim().Length == 0)
            {
                strErr += "status不能为空!\\n";
            }
            if (this.txtNote.Text.Trim().Length == 0)
            {
                strErr += "Note不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string  MapCode        = this.txtMapCode.Text;
            string  StormSystem_ID = this.txtStormSystem_ID.Text;
            string  Exp_No         = this.lblExp_No.Text;
            string  Type           = this.txtType.Text;
            decimal X             = decimal.Parse(this.txtX.Text);
            decimal Y             = decimal.Parse(this.txtY.Text);
            decimal High          = decimal.Parse(this.txtHigh.Text);
            decimal WellDeep      = decimal.Parse(this.txtWellDeep.Text);
            string  Offset        = this.txtOffset.Text;
            string  Feature       = this.txtFeature.Text;
            string  Subsid        = this.txtSubsid.Text;
            string  Model         = this.txtModel.Text;
            string  WellPipes     = this.txtWellPipes.Text;
            string  WellShape     = this.txtWellShape.Text;
            string  WellSize      = this.txtWellSize.Text;
            string  WellMaterial  = this.txtWellMaterial.Text;
            decimal WaterDeep     = decimal.Parse(this.txtWaterDeep.Text);
            decimal MudDeep       = decimal.Parse(this.txtMudDeep.Text);
            string  Inlet_Type    = this.txtInlet_Type.Text;
            string  OutfallType   = this.txtOutfallType.Text;
            string  ReceiveWater  = this.txtReceiveWater.Text;
            string  Flap          = this.txtFlap.Text;
            decimal Flap_Diameter = decimal.Parse(this.txtFlap_Diameter.Text);
            decimal Flap_TopEle   = decimal.Parse(this.txtFlap_TopEle.Text);
            decimal Flap_BotEle   = decimal.Parse(this.txtFlap_BotEle.Text);
            string  Flap_Material = this.txtFlap_Material.Text;
            string  Address       = this.txtAddress.Text;
            string  PointPosition = this.txtPointPosition.Text;
            string  DataSource    = this.txtDataSource.Text;
            string  Visibility    = this.txtVisibility.Text;
            string  Sdate         = this.txtSdate.Text;
            string  Mdate         = this.txtMdate.Text;
            string  Manhole_Type  = this.txtManhole_Type.Text;
            string  status        = this.txtstatus.Text;
            string  Note          = this.txtNote.Text;


            Maticsoft.Model.cjplp model = new Maticsoft.Model.cjplp();
            model.MapCode        = MapCode;
            model.StormSystem_ID = StormSystem_ID;
            model.Exp_No         = Exp_No;
            model.Type           = Type;
            model.X             = X;
            model.Y             = Y;
            model.High          = High;
            model.WellDeep      = WellDeep;
            model.Offset        = Offset;
            model.Feature       = Feature;
            model.Subsid        = Subsid;
            model.Model         = Model;
            model.WellPipes     = WellPipes;
            model.WellShape     = WellShape;
            model.WellSize      = WellSize;
            model.WellMaterial  = WellMaterial;
            model.WaterDeep     = WaterDeep;
            model.MudDeep       = MudDeep;
            model.Inlet_Type    = Inlet_Type;
            model.OutfallType   = OutfallType;
            model.ReceiveWater  = ReceiveWater;
            model.Flap          = Flap;
            model.Flap_Diameter = Flap_Diameter;
            model.Flap_TopEle   = Flap_TopEle;
            model.Flap_BotEle   = Flap_BotEle;
            model.Flap_Material = Flap_Material;
            model.Address       = Address;
            model.PointPosition = PointPosition;
            model.DataSource    = DataSource;
            model.Visibility    = Visibility;
            model.Sdate         = Sdate;
            model.Mdate         = Mdate;
            model.Manhole_Type  = Manhole_Type;
            model.status        = status;
            model.Note          = Note;

            Maticsoft.BLL.cjplp bll = new Maticsoft.BLL.cjplp();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
コード例 #2
0
        /// <summary>
        /// 上传点表
        /// </summary>
        /// <returns></returns>
        private bool UpLoadPointSheet()
        {
            try
            {
                if (String.IsNullOrEmpty(this.textEditPointSheet.Text))
                {
                    MessageBox.Show("点表表单为空!请选择点表", "提示");
                    return(true);
                }

                DataSet   dataSet   = ExcelToDataSet(excelPath, this.textEditPointSheet.Text.Trim());
                DataTable dataTable = dataSet.Tables[0];

                //1.填充数据名称和数据上传时间字段
                dataTable.Columns.Add("FileName", typeof(string));
                dataTable.Columns.Add("Uploadtime", typeof(string));
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    dataTable.Rows[i]["FileName"] = Path.GetFileNameWithoutExtension(excelPath);

                    dataTable.Rows[i]["Uploadtime"] = DateTime.Now.ToString();
                }

                cjplp cjplpBLL = new cjplp();



                List <Maticsoft.Model.cjplp> cjplpModelList = cjplpBLL.DataTableToList(dataTable);

                cjplpback cjplpBackBLL = new cjplpback();
                List <Maticsoft.Model.cjplpback> cjplpBackModelList = cjplpBackBLL.DataTableToList(dataTable);

                exportinfo exportinfoBLL = new exportinfo();
                Maticsoft.Model.exportinfo exportinfoModel = new Maticsoft.Model.exportinfo();


                for (int i = 0; i < cjplpModelList.Count; i++)
                {
                    List <Maticsoft.Model.exportinfo> exportinfosModelList = exportinfoBLL.GetModelList("");

                    //不重复的数据
                    if (!cjplpBLL.Exists(cjplpModelList[i].Exp_NoOri))
                    {
                        //点表不重复的数据,直接插入
                        cjplpBLL.Add(cjplpModelList[i]);
                    }
                    else
                    {
                        //存在就更新点表中原有的数据,因为可能只修改了数据的属性
                        cjplpBLL.Update(cjplpModelList[i]);

                        //备份的数据库中,不重复的数据,则插入,否则,则更新
                        if (!cjplpBackBLL.Exists(cjplpModelList[i].Exp_NoOri))
                        {
                            cjplpBackBLL.Add(cjplpBackModelList[i]);
                        }
                        else
                        {
                            cjplpBackBLL.Update(cjplpBackModelList[i]);
                        }
                    }

                    //导出配置表(exportinfo)中有配置数据,则对比
                    if (exportinfosModelList.Count > 0)
                    {
                        Int32 flag = 0;
                        //导出表的配置
                        for (int j = 0; j < exportinfosModelList.Count; j++)
                        {
                            if (exportinfosModelList[j].Address != cjplpModelList[i].Address ||
                                !cjplpModelList[i].FileName.Contains(exportinfosModelList[j].Basin) ||
                                !cjplpModelList[i].FileName.Contains(exportinfosModelList[j].Strname) ||
                                !cjplpModelList[i].FileName.Contains(exportinfosModelList[j].Plot))
                            {
                                flag++;
                            }

                            if (flag == exportinfosModelList.Count)
                            {
                                string[] tempArr = cjplpModelList[i].FileName.Split('-');
                                //导出配置表(exportinfo)中没有配置数据,则直接插入
                                exportinfoModel.Address = cjplpModelList[i].Address;

                                exportinfoModel.Basin   = tempArr.Length > 0 ? tempArr[0] : string.Empty;
                                exportinfoModel.Strname = tempArr.Length > 1 ? tempArr[1] : string.Empty;
                                exportinfoModel.Plot    = tempArr.Length > 2 ? tempArr[2].Substring(0, tempArr[2].IndexOf("_")) : string.Empty;

                                exportinfoModel.FileName = cjplpModelList[i].FileName;
                                exportinfoBLL.Add(exportinfoModel);
                            }
                        }
                    }
                    else
                    {
                        string[] tempArr = cjplpModelList[i].FileName.Split('-');
                        //导出配置表(exportinfo)中没有配置数据,则直接插入
                        exportinfoModel.Address = cjplpModelList[i].Address;

                        exportinfoModel.Basin   = tempArr.Length > 0 ? tempArr[0] : string.Empty;
                        exportinfoModel.Strname = tempArr.Length > 1 ? tempArr[1] : string.Empty;
                        exportinfoModel.Plot    = tempArr.Length > 2 ? tempArr[2].Substring(0, tempArr[2].IndexOf("_")) : string.Empty;

                        exportinfoModel.FileName = cjplpModelList[i].FileName;
                        exportinfoBLL.Add(exportinfoModel);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(false);
        }