📄 agentoperte.cs
字号:
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.label12);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.button2);
this.Controls.Add(this.textBox10);
this.Controls.Add(this.textBox9);
this.Controls.Add(this.textBox8);
this.Controls.Add(this.textBox7);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label4);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "agentoperte";
this.Load += new System.EventHandler(this.agentoperte_Load);
this.ResumeLayout(false);
}
#endregion
private void agentoperte_Load(object sender, System.EventArgs e)
{
if (agent == "me")
{
this.label5.Visible = false;
this.button5.Enabled = false;
this.button1.Visible = false;
this.button3.Visible = false;
}
else
{
this.button4.Visible = false;
this.button5.Visible = false;
this.button6.Visible = false;
}
this.textBox1.Text = "";
this.textBox2.Text = "";
this.textBox3.Text = "";
this.textBox10.Text = "";
//this.textBox4.Text = "";
//this.textBox5.Text = "";
this.textBox6.Text = "";
this.textBox7.Text = "";
this.textBox8.Text = "";
this.textBox9.Text = "";
}
private void label7_Click(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
if (this.textBox1.Text.Trim() == "")
{
MessageBox.Show("维护员编号不能为空!");
this.textBox1.Focus();
}
else
{
if (this.textBox2.Text.Trim() == "")
{
MessageBox.Show("名称不能为空!");
this.textBox2.Focus();
}
else
{
if (this.textBox3.Text.Trim() == "")
{
MessageBox.Show("地址不能为空!");
this.textBox3.Focus();
}
else
{
bool check = false;
Connection s = new Connection();
SqlConnection conn = new SqlConnection(s.getConnectionString);
conn.Open();
string str = "select * from agent";
SqlCommand cmd = new SqlCommand(str,conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (this.textBox1.Text.Trim() == Convert.ToString(dr["agentNo"]))
{
check = true;
break;
}
}
dr.Close();
conn.Close();
//SqlConnection conn = new
if (!check)
{
serviceAgent agt = new serviceAgent();
agt.Open();
bool flag = agt.addAgent(this.textBox1.Text,this.textBox2.Text,this.textBox3.Text,this.textBox6.Text,this.textBox7.Text,this.textBox8.Text,this.textBox9.Text,this.textBox10.Text);
if (flag)
MessageBox.Show("注册成功!");
else
MessageBox.Show("注册失败!");
agt.Close();
}
else
{
MessageBox.Show("维护商编号已存在!");
this.textBox1.Text = "";
this.textBox1.Focus();
}
}
}
}
//serviceAgent agt = new serviceAgent();
//agt.Open();
//bool flag = agt.addAgent(this.textBox1.Text,this.textBox2.Text,this.textBox3.Text,this.textBox4.Text,this.textBox5.Text,this.textBox6.Text,this.textBox7.Text,this.textBox8.Text,this.textBox9.Text,this.textBox10.Text);
//if (flag)
// MessageBox.Show("注册成功!");
//else
// MessageBox.Show("注册失败!");
//agt.Close();
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void label1_Click(object sender, System.EventArgs e)
{
}
private void textBox5_TextChanged(object sender, System.EventArgs e)
{
this.checking = true;
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
if (this.textBox1.Text.Trim().Length > 10)
{
MessageBox.Show("输入数据无效!");
this.textBox1.Text = "";
this.textBox1.Focus();
}
}
private void textBox2_TextChanged(object sender, System.EventArgs e)
{
this.checking = true;
if (this.textBox2.Text.Trim().Length > 20)
{
MessageBox.Show("输入数据无效!");
this.textBox2.Text = "";
this.textBox2.Focus();
}
}
private void textBox3_TextChanged(object sender, System.EventArgs e)
{
this.checking = true;
if (this.textBox3.Text.Trim().Length > 30)
{
MessageBox.Show("输入数据无效!");
this.textBox3.Text = "";
this.textBox3.Focus();
}
}
private void textBox6_TextChanged(object sender, System.EventArgs e)
{
this.checking = true;
if (this.textBox6.Text.Trim().Length > 20)
{
MessageBox.Show("输入数据无效!");
this.textBox6.Text = "";
this.textBox6.Focus();
}
}
private void textBox7_TextChanged(object sender, System.EventArgs e)
{
this.checking = true;
string s = "";
if (this.textBox7.Text.Trim().Length > 20)
{
MessageBox.Show("输入数据无效!");
this.textBox7.Text = "";
this.textBox7.Focus();
}
else
{
if (this.textBox7.Text.Trim() != "")
{
s = this.textBox7.Text.Trim();
for (int i = 0;i < s.Length;i++)
{
if (s[i] >= '0'&& s[i] <= '9')
{
continue;
}
else
{
MessageBox.Show(" 电话号码为数字!");
this.textBox7.Text = "";
this.textBox7.Focus();
}
}
}
}
}
private void textBox8_TextChanged(object sender, System.EventArgs e)
{
this.checking = true;
if (this.textBox8.Text.Trim().Length > 20)
{
MessageBox.Show("输入数据无效!");
this.textBox8.Text = "";
this.textBox8.Focus();
}
}
private void textBox9_TextChanged(object sender, System.EventArgs e)
{
this.checking = true;
if (this.textBox9.Text.Trim().Length > 20)
{
MessageBox.Show("输入数据无效!");
this.textBox9.Text = "";
this.textBox9.Focus();
}
}
private void textBox10_TextChanged(object sender, System.EventArgs e)
{
this.checking = true;
if (this.textBox10.Text.Trim().Length > 20)
{
MessageBox.Show("输入数据无效!");
this.textBox10.Text = "";
this.textBox10.Focus();
}
}
private void button4_Click(object sender, System.EventArgs e)
{
if (this.textBox1.Text.Trim() == "")
{
MessageBox.Show("请输入维护商编号!");
this.textBox1.Focus();
}
else
{
bool check = true;
Connection s = new Connection();
SqlConnection conn = new SqlConnection(s.getConnectionString);
conn.Open();
string str = "select * from agent";
SqlCommand cmd = new SqlCommand(str,conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (this.textBox1.Text.Trim() == Convert.ToString(dr["agentNo"]))
{
this.textBox1.ReadOnly = false;
this.button5.Enabled = true;
check = false;
this.textBox2.Text = Convert.ToString(dr["agentName"]);
this.textBox3.Text = Convert.ToString(dr["agentAddress"]);
this.textBox6.Text = Convert.ToString(dr["agentZipCode"]);
this.textBox7.Text = Convert.ToString(dr["agentTelNo"]);
this.textBox8.Text = Convert.ToString(dr["agentFaxNo"]);
this.textBox9.Text = Convert.ToString(dr["agentEmail"]);
this.textBox10.Text = Convert.ToString(dr["agentWebSite"]);
break;
}
}
dr.Close();
conn.Close();
if (check)
{
MessageBox.Show("输入的编号不正确!");
this.textBox1.Text = "";
this.textBox1.Focus();
}
}
}
private void button5_Click(object sender, System.EventArgs e)
{
if (this.textBox2.Text.Trim() == "")
{
MessageBox.Show("维护商名称不能为空!");
this.textBox2.Focus();
}
else
{
if (this.textBox3.Text.Trim() == "")
{
MessageBox.Show("维护商地址不能为空!");
this.textBox3.Focus();
}
else
{
Connection s = new Connection();
SqlConnection conn = new SqlConnection(s.getConnectionString);
conn.Open();
serviceAgent agt = new serviceAgent();
agt.Open();
bool flag = agt.modifyAgent(this.textBox1.Text,this.textBox2.Text,this.textBox3.Text,this.textBox6.Text,this.textBox7.Text,this.textBox8.Text,this.textBox9.Text,this.textBox10.Text);
if (checking)
{
if (flag)
MessageBox.Show("修改成功!");
else
MessageBox.Show("修改失败!");
}
this.textBox1.ReadOnly = false;
agt.Close();
conn.Close();
}
}
}
private void button6_Click(object sender, System.EventArgs e)
{
this.textBox1.ReadOnly = false;
this.button5.Enabled = false;
this.textBox1.Text = "";
this.textBox2.Text = "";
this.textBox3.Text = "";
this.textBox10.Text = "";
//this.textBox4.Text = "";
//this.textBox5.Text = "";
this.textBox6.Text = "";
this.textBox7.Text = "";
this.textBox8.Text = "";
this.textBox9.Text = "";
}
}
}
//agentName, agentAddress, agentZipCode, agentTelNo, agentFaxNo,string agentEmail,string agentWebSite)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -