using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace PowerTalkClient
{
public partial class FrmClientAdd : Form
{
public string ModID = "";
public FrmClientAdd()
{
InitializeComponent();
}
public bool Mod = false;
///
/// 修改保存
///
///
public FrmClientAdd(string Id)
{
InitializeComponent();
ModID = Id;
Mod = true;
AddOrSave.Text = "更新";
OleDbConnection Conn = Common.OleSysConn;
Conn.Open();
try
{
OleDbCommand Cmd = new OleDbCommand("select * from 客户信息", Conn);
OleDbDataReader dr = Cmd.ExecuteReader();
if (dr.Read())
{
xingming_textBox.Text = dr["姓名"].ToString();
nicheng_textBox.Text = dr["昵称"].ToString();
xingbie_comboBox.Text = dr["性别"].ToString();
gudingdianhua_textbox.Text = dr["固定电话"].ToString();
shoujihaoma_textbox.Text = dr["手机号码"].ToString();
Email_textBox.Text = dr["Email"].ToString();
QQ_textBox.Text = dr["QQ"].ToString();
MSN_textBox.Text = dr["MSN"].ToString();
gongsi_textBox.Text = dr["公司"].ToString();
dizhi_textBox.Text = dr["地址"].ToString();
wangzhi_textBox.Text = dr["网址"].ToString();
yixiang_comboBox.Text = dr["分类"].ToString();
xiangxidizhi_textbox.Text = dr["详细地址"].ToString();
dengluIP_textBox.Text = dr["登录IP"].ToString();
dingyue_checkBox.Checked = bool.Parse(dr["订阅与否"].ToString());
beizhu_textBox.Text = dr["备注"].ToString();
}
}
catch
{ }
finally { Conn.Close(); }
}
///
/// 添加
///
public FrmClientAdd(string xingmingstr,string ipstr,string xiangxidizhistr)
{
InitializeComponent();
nicheng_textBox.Text = xingmingstr;
dengluIP_textBox.Text = ipstr;
xiangxidizhi_textbox.Text = xiangxidizhistr;
}
//5#1#a#s#p#x
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void AddOrSave_Click(object sender, EventArgs e)
{
if (!Mod)
{
OleDbConnection conn = Common.OleSysConn;
conn.Open();
OleDbCommand cmd = new OleDbCommand();
try
{
string SqlStr = "insert into 客户信息(姓名,昵称,性别,固定电话,手机号码,Email,QQ,MSN,公司,地址,网址,分类,详细地址,登录IP,订阅与否,备注) ";
SqlStr += "values('" + xingming_textBox.Text + "','" + nicheng_textBox.Text + "','" + xingbie_comboBox.Text + "','" + gudingdianhua_textbox.Text + "','" + shoujihaoma_textbox.Text + "','" + Email_textBox.Text + "','" + QQ_textBox.Text + "','" + MSN_textBox.Text + "','" + gongsi_textBox.Text + "','" + dizhi_textBox.Text + "','" + wangzhi_textBox.Text + "','" + yixiang_comboBox.Text + "','" + xiangxidizhi_textbox.Text + "','" + dengluIP_textBox.Text + "','" + dingyue_checkBox.Checked.ToString() + "','" + beizhu_textBox.Text + "')";
cmd.Connection = conn;
cmd.CommandText = SqlStr;
cmd.ExecuteNonQuery();
MessageBox.Show("添加成功!");
}
catch (Exception exp)
{
MessageBox.Show("添加失败!" + exp.Message);
}
finally
{
conn.Close();
}
}
else
{
OleDbConnection conn = Common.OleSysConn;
conn.Open();
OleDbCommand cmd = new OleDbCommand();
try
{
string SqlStr = "update 客户信息 set 姓名='" + xingming_textBox.Text + "',昵称='" + nicheng_textBox.Text + "',性别='" + xingbie_comboBox.Text + "',固定电话='" + gudingdianhua_textbox.Text + "',手机号码='" + shoujihaoma_textbox.Text + "',Email='" + Email_textBox.Text + "',QQ='" + QQ_textBox.Text + "',MSN='" + MSN_textBox.Text + "',公司='" + gongsi_textBox.Text + "',地址='" + dizhi_textBox.Text + "',网址='" + wangzhi_textBox.Text + "',分类='" + yixiang_comboBox.Text + "',详细地址='" + xiangxidizhi_textbox.Text + "',登录IP='" + dengluIP_textBox.Text + "',订阅与否='" + dingyue_checkBox.Checked.ToString() + "',备注='" + beizhu_textBox.Text + "' where ID=" + ModID;
cmd.Connection = conn;
cmd.CommandText = SqlStr;
cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
}
catch (Exception exp)
{
MessageBox.Show("修改失败!" + exp.Message);
}
finally
{
conn.Close();
}
}
this.Close();
}
private void FrmClientAdd_Load(object sender, EventArgs e)
{
}
}
}
/////////////////////////5///1///a///s///p///x//////////////////////////////
No comments:
Post a Comment