using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace demo_Builder1
{
public partial class Add_BookMessage : Form
{
SqlConn sqlconn;
public Add_BookMessage()
{
InitializeComponent();
}
private void Add_BookMessage_Load(object sender, EventArgs e)
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
}
private void button3_Click(object sender, EventArgs e)
{
this.Dispose();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if(Sql_Select()>0)
{
string sql_select = string.Format("update Erp_MessageManage set Erp_Inventory=Erp_Inventory+1 where Erp_BookGigClass='{0}' and Erp_BookSmallClass='{1}'and Erp_BookComeIn='{2}' and Erp_BookNumber='{3}'", this.textBox1.Text, this.textBox2.Text, this.textBox4.Text, this.textBox5.Text, this.textBox3.Text);
sqlconn = new SqlConn();
sqlconn.SqlInitail(sql_select);
sqlconn.GetSqlConnection.Open();
int num = Convert.ToInt32(sqlconn.GetSqlCommand.ExecuteNonQuery());
if(num>0)
{
MessageBox.Show("该类别信息已经存在并且库存已经更新成功");
}
}
else if (Sql_Insert() > 0)
{
MessageBox.Show("添加成功");
}
else
{
MessageBox.Show("添加失败");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
sqlconn.GetSqlConnection.Close();
}
}
private int Sql_Select()
{
string sql_select = string.Format("select count(*) from Erp_MessageManage where Erp_BookGigClass='{0}' and Erp_BookSmallClass='{1}'and Erp_BookComeIn='{2}' and Erp_BookNumber='{3}'", this.textBox1.Text, this.textBox2.Text, this.textBox4.Text, this.textBox5.Text, this.textBox3.Text);
sqlconn = new SqlConn();
sqlconn.SqlInitail(sql_select);
sqlconn.GetSqlConnection.Open();
int num = Convert.ToInt32(sqlconn.GetSqlCommand.ExecuteScalar());
return num;
}
private int Sql_Insert()
{
string sql_insert = string.Format("insert into Erp_MessageManage(Erp_BookGigClass,Erp_BookSmallClass,Erp_BookComeIn,Erp_BookNumber,Erp_BookInventoryNumber)values('{0}','{1}','{2}','{3}','{4}')", this.textBox1.Text, this.textBox2.Text, this.textBox4.Text, this.textBox5.Text, this.textBox3.Text);
sqlconn = new SqlConn();
sqlconn.SqlInitail(sql_insert);
sqlconn.GetSqlConnection.Open();
int num = Convert.ToInt32(sqlconn.GetSqlCommand.ExecuteNonQuery());
return num;
}
}
}
|