public MODELBASE_COMMUNITY GetMODELBASE_COMMUNITY(string strDepID) { DataTable dt = new DataTable(); MODELBASE_COMMUNITY MODELBASE_COMMUNITY = new MODELBASE_COMMUNITY(); StringBuilder str = new StringBuilder(); str.Append("SELECT * FROM BASE_COMMUNITY WHERE COMMUNITYID=@COMMUNITYID"); SqlParameter[] para = { new SqlParameter("@COMMUNITYID", SqlDbType.VarChar, 30) }; para[0].Value = strDepID; dt = DBUtility.DbHelperSQL.Query(str.ToString(), para).Tables[0]; if (dt.Rows.Count == 0) { return(null); } else { MODELBASE_COMMUNITY.COMMUNITYNAME = dt.Rows[0]["COMMUNITYNAME"].ToString(); if (dt.Rows[0]["PARENTID"] != null) { MODELBASE_COMMUNITY.PARENTID = dt.Rows[0]["PARENTID"].ToString(); } if (dt.Rows[0]["MEMO"] != null) { MODELBASE_COMMUNITY.MEMO = dt.Rows[0]["MEMO"].ToString(); } return(MODELBASE_COMMUNITY); } }
public bool Insert(MODELBASE_COMMUNITY MODELBASE_COMMUNITY) { StringBuilder str = new StringBuilder(); str.Append("INSERT INTO BASE_COMMUNITY(COMMUNITYID,COMMUNITYNAME,PARENTID,MEMO) "); str.Append("VALUES(@COMMUNITYID,@COMMUNITYNAME,@PARENTID,@MEMO)"); SqlParameter[] para = { new SqlParameter("@COMMUNITYID", SqlDbType.VarChar, 30), new SqlParameter("@COMMUNITYNAME", SqlDbType.VarChar, 50), new SqlParameter("@PARENTID", SqlDbType.VarChar, 30), new SqlParameter("@MEMO", SqlDbType.VarChar, 50) }; para[0].Value = MODELBASE_COMMUNITY.COMMUNITYID; para[1].Value = MODELBASE_COMMUNITY.COMMUNITYNAME; para[2].Value = MODELBASE_COMMUNITY.PARENTID; para[3].Value = MODELBASE_COMMUNITY.MEMO; if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0) { return(true); } else { return(false); } }
public bool Update(MODELBASE_COMMUNITY MODELBASE_COMMUNITY) { StringBuilder str = new StringBuilder(); str.Append("UPDATE BASE_COMMUNITY SET COMMUNITYNAME=@COMMUNITYNAME,MEMO=@MEMO "); str.Append("WHERE COMMUNITYID=@COMMUNITYID"); SqlParameter[] para = { new SqlParameter("@COMMUNITYNAME", SqlDbType.VarChar, 50), new SqlParameter("@MEMO", SqlDbType.VarChar, 50), new SqlParameter("@COMMUNITYID", SqlDbType.VarChar, 50) }; para[0].Value = MODELBASE_COMMUNITY.COMMUNITYNAME; para[1].Value = MODELBASE_COMMUNITY.MEMO; para[2].Value = MODELBASE_COMMUNITY.COMMUNITYID; if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0) { return(true); } else { return(false); } }
private void toolSubmit_Click(object sender, EventArgs e) { if (!IsADD && tvDep.SelectedNode.Tag.ToString() == "0000") { mes.Show("该小区无法删除或修改!"); return; } if (txtName.Text.Trim() == "") { mes.Show("请填写小区名称!"); txtName.Focus(); return; } MODELBASE_COMMUNITY MODELBASE_COMMUNITY = new MODELBASE_COMMUNITY(); MODELBASE_COMMUNITY.COMMUNITYNAME = txtName.Text; MODELBASE_COMMUNITY.PARENTID = "0000"; MODELBASE_COMMUNITY.MEMO = txtMemo.Text; if (IsADD) { MODELBASE_COMMUNITY.COMMUNITYID = GETTABLEID.GetTableID("", "BASE_COMMUNITY"); } else { MODELBASE_COMMUNITY.COMMUNITYID = txtID.Text; } try { if (IsADD) { if (BLLBASE_COMMUNITY.Insert(MODELBASE_COMMUNITY)) { tvDep.Enabled = true; tvDep.Nodes.Clear(); AddTreeNode("0", null); toolAdd.Text = "添加"; toolAdd.Enabled = true; GetSelectedNode(tvDep.Nodes[0], MODELBASE_COMMUNITY.COMMUNITYID); } } else { if (BLLBASE_COMMUNITY.Update(MODELBASE_COMMUNITY)) { tvDep.Enabled = true; tvDep.Nodes.Clear(); AddTreeNode("0", null); GetSelectedNode(tvDep.Nodes[0], MODELBASE_COMMUNITY.COMMUNITYID); } } } catch (Exception ex) { lg.Write(ex.ToString(), MsgType.Error); mes.Show(ex.Message.ToString()); return; } IsADD = false; }
private void tvDep_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node == null) { return; } string strDepID = e.Node.Tag.ToString(); MODELBASE_COMMUNITY MODELBASE_COMMUNITY = new MODELBASE_COMMUNITY(); MODELBASE_COMMUNITY = BLLBASE_COMMUNITY.GetMODELBASE_COMMUNITY(strDepID); txtID.Text = strDepID; txtName.Text = MODELBASE_COMMUNITY.COMMUNITYNAME; txtMemo.Text = MODELBASE_COMMUNITY.MEMO; }