示例#1
0
 /// <summary>
 /// 数据操作
 /// </summary>
 /// <param name="Mess">区别编辑还是新增还是删除</param>
 private bool OpreationDB(string Mess, CADS.Model.GeographyEnvInfoList geographyEnvInfo)
 {
     try
     {
         string Error  = "";
         bool   Result = false;
         if (Mess == "添加")
         {
             Result = geographyEnv.Add(geographyEnvInfo);
         }
         if (Mess == "编辑")
         {
             Result = geographyEnv.Update(geographyEnvInfo);
         }
         if (Mess == "删除")
         {
             Result = geographyEnv.Delete(geographyEnvInfo.ZoneID);
         }
         if (Result == true)
         {
             MessageBox.Show("预案信息" + Mess + "成功");
             return(true);
         }
         else
         {
             MessageBox.Show("预案信息" + Mess + "失败,请稍后再试!");
             return(false);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("预案信息" + Mess + "失败:" + e.Message);
         return(false);
     }
 }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CADS.Model.GeographyEnvInfoList model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.ZoneID != null)
            {
                strSql1.Append("ZoneID,");
                strSql2.Append("'" + model.ZoneID + "',");
            }
            if (model.ZoneScale != null)
            {
                strSql1.Append("ZoneScale,");
                strSql2.Append("'" + model.ZoneScale + "',");
            }
            if (model.GeographyEnv != null)
            {
                strSql1.Append("GeographyEnv,");
                strSql2.Append("'" + model.GeographyEnv + "',");
            }
            if (model.RoadTransport != null)
            {
                strSql1.Append("RoadTransport,");
                strSql2.Append("'" + model.RoadTransport + "',");
            }
            if (model.WaterSystem != null)
            {
                strSql1.Append("WaterSystem,");
                strSql2.Append("'" + model.WaterSystem + "',");
            }
            if (model.Description != null)
            {
                strSql1.Append("Description,");
                strSql2.Append("'" + model.Description + "',");
            }
            if (model.Mark != null)
            {
                strSql1.Append("Mark,");
                strSql2.Append("'" + model.Mark + "',");
            }
            strSql.Append("insert into GeographyEnvInfoList(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
 public Form_GeographyEnvAdd(string operType, CADS.Model.GeographyEnvInfoList geographyEnvInfo)
 {
     InitializeComponent();
     this.operType = operType;
     if (operType == "add")
     {
         Title_Label.Text = "战区地理环境添加";
     }
     else
     {
         Title_Label.Text      = "战区地理环境修改";
         this.geographyEnvInfo = geographyEnvInfo;
     }
 }
示例#4
0
 private void btn_Delete_Click(object sender, EventArgs e)
 {
     if (DataView.SelectedRows.Count < 1)
     {
         MessageBox.Show("请选中一行数据!");
         return;
     }
     if (MessageBox.Show("确定要删除该行数据?", null, MessageBoxButtons.YesNo) != DialogResult.Yes)
     {
         return;
     }
     CADS.Model.GeographyEnvInfoList geographyEnvInfo = new CADS.Model.GeographyEnvInfoList();
     geographyEnvInfo.ZoneID = DataView.CurrentRow.Cells[1].Value.ToString();
     OpreationDB("删除", geographyEnvInfo);
     RefreshDataGridView();
 }
示例#5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CADS.Model.GeographyEnvInfoList GetModel(string ZoneID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  ");
            strSql.Append(" ID,ZoneID,ZoneScale,GeographyEnv,RoadTransport,WaterSystem,Description,Mark ");
            strSql.Append(" from GeographyEnvInfoList ");
            strSql.Append(" where ZoneID='" + ZoneID + "' ");
            CADS.Model.GeographyEnvInfoList model = new CADS.Model.GeographyEnvInfoList();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CADS.Model.GeographyEnvInfoList DataRowToModel(DataRow row)
 {
     CADS.Model.GeographyEnvInfoList model = new CADS.Model.GeographyEnvInfoList();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["ZoneID"] != null)
         {
             model.ZoneID = row["ZoneID"].ToString();
         }
         if (row["ZoneScale"] != null)
         {
             model.ZoneScale = row["ZoneScale"].ToString();
         }
         if (row["GeographyEnv"] != null)
         {
             model.GeographyEnv = row["GeographyEnv"].ToString();
         }
         if (row["RoadTransport"] != null)
         {
             model.RoadTransport = row["RoadTransport"].ToString();
         }
         if (row["WaterSystem"] != null)
         {
             model.WaterSystem = row["WaterSystem"].ToString();
         }
         if (row["Description"] != null)
         {
             model.Description = row["Description"].ToString();
         }
         if (row["Mark"] != null)
         {
             model.Mark = row["Mark"].ToString();
         }
     }
     return(model);
 }
示例#7
0
        private void btn_Edit_Click(object sender, EventArgs e)
        {
            if (DataView.SelectedRows.Count < 1)
            {
                MessageBox.Show("请选中一行数据!");
                return;
            }
            CADS.Model.GeographyEnvInfoList geographyEnvInfo = new CADS.Model.GeographyEnvInfoList();
            geographyEnvInfo.ID            = Convert.ToInt32(DataView.CurrentRow.Cells[0].Value);
            geographyEnvInfo.ZoneID        = DataView.CurrentRow.Cells[1].Value.ToString();
            geographyEnvInfo.ZoneScale     = DataView.CurrentRow.Cells[2].Value.ToString();
            geographyEnvInfo.GeographyEnv  = DataView.CurrentRow.Cells[3].Value.ToString();
            geographyEnvInfo.RoadTransport = DataView.CurrentRow.Cells[4].Value.ToString();
            geographyEnvInfo.WaterSystem   = DataView.CurrentRow.Cells[5].Value.ToString();
            geographyEnvInfo.Description   = DataView.CurrentRow.Cells[6].Value.ToString();
            Form_GeographyEnvAdd addOrEdit = new Form_GeographyEnvAdd("edit", geographyEnvInfo);

            addOrEdit.ShowDialog();
            if (addOrEdit.DialogResult == DialogResult.OK)
            {
                OpreationDB("编辑", addOrEdit.geographyEnvInfo);
                RefreshDataGridView();
            }
        }
示例#8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CADS.Model.GeographyEnvInfoList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update GeographyEnvInfoList set ");
            if (model.ZoneScale != null)
            {
                strSql.Append("ZoneScale='" + model.ZoneScale + "',");
            }
            else
            {
                strSql.Append("ZoneScale= null ,");
            }
            if (model.GeographyEnv != null)
            {
                strSql.Append("GeographyEnv='" + model.GeographyEnv + "',");
            }
            else
            {
                strSql.Append("GeographyEnv= null ,");
            }
            if (model.RoadTransport != null)
            {
                strSql.Append("RoadTransport='" + model.RoadTransport + "',");
            }
            else
            {
                strSql.Append("RoadTransport= null ,");
            }
            if (model.WaterSystem != null)
            {
                strSql.Append("WaterSystem='" + model.WaterSystem + "',");
            }
            else
            {
                strSql.Append("WaterSystem= null ,");
            }
            if (model.Description != null)
            {
                strSql.Append("Description='" + model.Description + "',");
            }
            else
            {
                strSql.Append("Description= null ,");
            }
            if (model.Mark != null)
            {
                strSql.Append("Mark='" + model.Mark + "',");
            }
            else
            {
                strSql.Append("Mark= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where ZoneID='" + model.ZoneID + "' ");
            int rowsAffected = DbHelperOleDb.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }