Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CADS.Model.NationalSocialInfoList GetModel(string NationID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  ");
            strSql.Append(" ID,NationID,NationName,Religion,Habit,SocialGroup,Description,Mark ");
            strSql.Append(" from NationalSocialInfoList ");
            strSql.Append(" where NationID='" + NationID + "' ");
            CADS.Model.NationalSocialInfoList model = new CADS.Model.NationalSocialInfoList();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CADS.Model.NationalSocialInfoList DataRowToModel(DataRow row)
 {
     CADS.Model.NationalSocialInfoList model = new CADS.Model.NationalSocialInfoList();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["NationID"] != null)
         {
             model.NationID = row["NationID"].ToString();
         }
         if (row["NationName"] != null)
         {
             model.NationName = row["NationName"].ToString();
         }
         if (row["Religion"] != null)
         {
             model.Religion = row["Religion"].ToString();
         }
         if (row["Habit"] != null)
         {
             model.Habit = row["Habit"].ToString();
         }
         if (row["SocialGroup"] != null)
         {
             model.SocialGroup = row["SocialGroup"].ToString();
         }
         if (row["Description"] != null)
         {
             model.Description = row["Description"].ToString();
         }
         if (row["Mark"] != null)
         {
             model.Mark = row["Mark"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        private void btn_Edit_Click(object sender, EventArgs e)
        {
            if (DataView.SelectedRows.Count < 1)
            {
                MessageBox.Show("请选中一行数据!");
                return;
            }
            CADS.Model.NationalSocialInfoList nationalSocialInfo = new CADS.Model.NationalSocialInfoList();
            nationalSocialInfo.ID          = Convert.ToInt32(DataView.CurrentRow.Cells[0].Value);
            nationalSocialInfo.NationID    = DataView.CurrentRow.Cells[1].Value.ToString();
            nationalSocialInfo.NationName  = DataView.CurrentRow.Cells[2].Value.ToString();
            nationalSocialInfo.Religion    = DataView.CurrentRow.Cells[3].Value.ToString();
            nationalSocialInfo.Habit       = DataView.CurrentRow.Cells[4].Value.ToString();
            nationalSocialInfo.SocialGroup = DataView.CurrentRow.Cells[5].Value.ToString();
            nationalSocialInfo.Description = DataView.CurrentRow.Cells[6].Value.ToString();
            Form_NationSocietyAdd addOrEdit = new Form_NationSocietyAdd("edit", nationalSocialInfo);

            addOrEdit.ShowDialog();
            if (addOrEdit.DialogResult == DialogResult.OK)
            {
                OpreationDB("编辑", addOrEdit.nationalSocialInfo);
                RefreshDataGridView();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CADS.Model.NationalSocialInfoList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update NationalSocialInfoList set ");
            if (model.NationName != null)
            {
                strSql.Append("NationName='" + model.NationName + "',");
            }
            else
            {
                strSql.Append("NationName= null ,");
            }
            if (model.Religion != null)
            {
                strSql.Append("Religion='" + model.Religion + "',");
            }
            else
            {
                strSql.Append("Religion= null ,");
            }
            if (model.Habit != null)
            {
                strSql.Append("Habit='" + model.Habit + "',");
            }
            else
            {
                strSql.Append("Habit= null ,");
            }
            if (model.SocialGroup != null)
            {
                strSql.Append("SocialGroup='" + model.SocialGroup + "',");
            }
            else
            {
                strSql.Append("SocialGroup= 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 NationID='" + model.NationID + "' ");
            int rowsAffected = DbHelperOleDb.ExecuteSql(strSql.ToString());

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