using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Consumable_Control_System_V1._00
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new LOGIN());
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Drawing;
using System.Collections;
using System.Windows;
using System.Threading;
using System.Data;
using System.Web;
using System.Net;
using System.Net.NetworkInformation;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
namespace Consumable_Control_System_V1._00
{
public class OperationDataBase
{
public String SERVER;
public String DATABASE;
public String UID;
public String PWD;
public String Connection;
public String Stored_Procedure;
public int Temp;
public Boolean Stat;
//public List<String> SqlCommand_List;
public OperationDataBase(String SERVER, String DATABASE, String UID, String PWD,String Stored_Procedure)
{
this.SERVER = SERVER;
this.DATABASE = DATABASE;
this.UID = UID;
this.PWD = PWD;
this.Connection = @"server=" + this.SERVER + ";database=" + this.DATABASE + ";uid=" + this.UID + ";pwd=" + this.PWD;
this.Stored_Procedure = Stored_Procedure;
}
//读取领用其它值
public Boolean Get_Picking_Other(TextBox Item_1, String TI_1, String TI_2, PictureBox PItem, String TI_6)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure, sqlcon);
SqlDataReader srd = cmd.ExecuteReader();
while (srd.Read())
{
Item_1.Text = srd[TI_1].ToString();
Temp = Convert.ToInt32(srd[TI_2].ToString());
//Item_4.Text = srd[TI_4].ToString();
//Item_5.Text = srd[TI_5].ToString();
byte[] ImageLogoArray = srd[TI_6] is DBNull ? null : (byte[])(srd[TI_6]);
MemoryStream ms = null;
if (ImageLogoArray != null)
{
ms = new MemoryStream(ImageLogoArray);
PItem.Image = new Bitmap(ms);
}
}
Flag = true;
}
catch (Exception ex)
{
Flag = false;
MessageBox.Show(ex.ToString(), "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
sqlcon.Close();
}
return Flag;
}
//获取用户信息
public Boolean Get_User_Info(List<String> User_List)
{
Boolean Flag = false;
SqlConnection sqlcom = new SqlConnection(this.Connection);
sqlcom.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcom);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
User_List.Add(sdr["User_NameID"].ToString() + "," + sdr["User_User_PwdID"].ToString()+","+
sdr["HandLers"].ToString() + "," + sdr["Department"].ToString() + "," + sdr["User_Grade"].ToString());
}
Flag = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
finally
{
sqlcom.Close();
}
return Flag;
}
//读取退还其它值
public Boolean Get_Picking_And_Return_Of_Material_Other(TextBox Item_1, String TI_1, TextBox Item_2, String TI_2, PictureBox PItem, String TI_6)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
SqlDataReader srd = cmd.ExecuteReader();
while (srd.Read())
{
Item_1.Text = srd[TI_1].ToString();
Item_2.Text = srd[TI_2].ToString();
//Item_4.Text = srd[TI_4].ToString();
//Item_5.Text = srd[TI_5].ToString();
byte[] ImageLogoArray = srd[TI_6] is DBNull ? null : (byte[])(srd[TI_6]);
MemoryStream ms = null;
if (ImageLogoArray != null)
{
ms = new MemoryStream(ImageLogoArray);
PItem.Image = new Bitmap(ms);
}
}
Flag = true;
}
catch (Exception ex)
{
Flag = false;
MessageBox.Show(ex.ToString(), "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
sqlcon.Close();
}
return Flag;
}
//领用总数
public int Brought_Back_Total_Count(String ItemName,String ItemName_2, String Material_Code)
{
int Total=0;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Material_Code", Material_Code);
cmd.Parameters.Add(ItemName, SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.ExecuteScalar();
Total = Convert.ToInt32(cmd.Parameters[ItemName].Value.ToString());
this.Stat = true;
}
catch (Exception ex)
{
MessageBox.Show(ItemName_2 + "\n" + ex.ToString(), "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Stat = false;
}
finally
{
sqlcon.Close();
}
return Total;
}
//获取查询指令集
public Boolean GetQuerying_Lit(ComboBox Item, List<String> Temp)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
//int n = 0;
String Args_1 = String.Empty;
Item.Items.Clear();
while (sdr.Read())
{
Boolean pp = true;
if (Args_1 != sdr["Item_Name"].ToString())
{
foreach (String ss in Item.Items)
{
if (ss == sdr["Item_Name"].ToString())
{
pp = false;
break;
}
}
if (pp ==true)
Item.Items.Add(sdr["Item_Name"].ToString());
Args_1 = sdr["Item_Name"].ToString();
//n = Convert.ToInt32(sdr["Op_Item"].ToString());
}
Temp.Add(sdr["Item_Name"].ToString() + "#" + sdr["Querying_Item_Name"].ToString() + "#" + sdr["Querying_Grammar"].ToString());
}
Flag = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}
//查询数据生成表格
public String Label_Str;
public Boolean Querying_Write_Data_Table(DataGridView aa)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds,"cs");
aa.DataSource = ds.Tables[0];
aa.HorizontalScrollingOffset = 0;
aa.ReadOnly = true;
aa.DefaultCellStyle.SelectionBackColor = Color.GreenYellow;
Label_Str = "已查询到数据:" + (aa.Rows.Count - 1).ToString() + "条";
Flag = true;
}
catch (Exception ex)
{
Flag = false;
MessageBox.Show(ex.ToString(), "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
sqlcon.Close();
}
return Flag;
}
//根据物品编码读取物品存储档案信息
public Boolean Get_Obtain_Data_From_Archival_Information(TextBox Item_1, String TI_1, TextBox Item_2, String TI_2, TextBox Item_3, String TI_3,
TextBox Item_4,String TI_4,PictureBox PItem, String TI_6)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
int n = 0;
while (sdr.Read())
{
Item_1.Text = sdr[TI_1].ToString();
Item_2.Text = sdr[TI_2].ToString();
Item_3.Text = sdr[TI_3].ToString();
Item_4.Text = sdr[TI_4].ToString();
byte[] ImageLogoArray = sdr[TI_6] is DBNull ? null : (byte[])(sdr[TI_6]);
MemoryStream ms = null;
if (ImageLogoArray != null)
{
ms = new MemoryStream(ImageLogoArray);
PItem.Image = new Bitmap(ms);
}
n++;
}
if (n > 0) Flag = true;
else
{
MessageBox.Show("无法从数据库中查询到对应物品代码数据,\n请确认是否输入代码错误或者该物品信息未作系统录入!!","系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}
//获取物品存储关键数据信息
public Boolean Get_Goods_Storage_Info(ComboBox Item_1, String TI_1,List<String>All_Storage_Data)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
String str = String.Empty;
while (sdr.Read())
{
if (str != sdr[TI_1].ToString())
{
Item_1.Items.Add(sdr[TI_1].ToString());
str = sdr[TI_1].ToString();
}
All_Storage_Data.Add(sdr[TI_1].ToString()+","+sdr["District"].ToString()+","+sdr["Shelf_Storage_CabinetNo"].ToString());
}
Flag = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}
//插入或更新物品档案
public Boolean Insert_Update_Item_Files(String Material_Code, String Trademark, String Product_Name, String Type_Specification, String Technical_Parameters, byte[] Product_Picture,
String Store_Floor, String Store_District, String Store_Shelf_Storage_CabinetNo, String Author)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Material_Code", Material_Code);
cmd.Parameters.Add("@Trademark", Trademark);
cmd.Parameters.Add("@Product_Name", Product_Name);
cmd.Parameters.Add("@Type_Specification", Type_Specification);
cmd.Parameters.Add("@Technical_Parameters", Technical_Parameters);
cmd.Parameters.Add("@Product_Picture", Product_Picture);
cmd.Parameters.Add("@Store_Floor", Store_Floor);
cmd.Parameters.Add("@Store_District", Store_District);
cmd.Parameters.Add("@Store_Shelf_Storage_CabinetNo", Store_Shelf_Storage_CabinetNo);
cmd.Parameters.Add("@Author", Author);
cmd.Parameters.Add("@rs",SqlDbType.Int).Direction=ParameterDirection.Output;
cmd.ExecuteScalar();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
MessageBox.Show("物品代码:" + Material_Code + "数据写入或更新成功!!", "系统提醒", MessageBoxButtons.OK);
Flag = true;
}
else
{
MessageBox.Show("物品代码:" + Material_Code + "数据写入或更新失败!!", "系统提醒", MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}
//根据物品条码查询物品档案信息
public Boolean Querying_Item_Files_Info(String Material_Code, TextBox Item_1, TextBox Item_2, TextBox Item_3, TextBox Item_4, TextBox Item_5, TextBox Item_6,
TextBox Item_7, RichTextBox Rtem_1,PictureBox PItem_1)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Material_Code",Material_Code);
cmd.Parameters.Add("@Trademark",SqlDbType.NVarChar,50).Direction=ParameterDirection.Output;
cmd.Parameters.Add("@Product_Name", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@Type_Specification",SqlDbType.NVarChar,150).Direction=ParameterDirection.Output;
cmd.Parameters.Add("@Technical_Parameters",SqlDbType.NVarChar,150).Direction=ParameterDirection.Output;
//cmd.Parameters.Add("@Product_Picture", SqlDbType.Image,(byte[])cmd["@Product_Picture"])).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@Storage_Location", SqlDbType.NVarChar, 150).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@Inventory", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@Number_Of_Recipients_Can",SqlDbType.Int).Direction=ParameterDirection.Output;
cmd.Parameters.Add("@Author", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@rs", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
SqlCommand cmd1 = new SqlCommand(@"select * from Item_Files where Material_Code='" + Material_Code+@"'", sqlcon);
SqlDataReader sdr=cmd1.ExecuteReader();
while (sdr.Read())
{
byte[] ImageLogoArray = sdr["Product_Picture"] is DBNull ? null : (byte[])(sdr["Product_Picture"]);
MemoryStream ms = null;
if (ImageLogoArray != null)
{
ms = new MemoryStream(ImageLogoArray);
PItem_1.Image = new Bitmap(ms);
}
}
Item_1.Text = cmd.Parameters["@Trademark"].Value.ToString();
Item_2.Text = cmd.Parameters["@Product_Name"].Value.ToString();
Item_3.Text = cmd.Parameters["@Type_Specification"].Value.ToString();
Item_4.Text = cmd.Parameters["@Technical_Parameters"].Value.ToString();
Item_5.Text = cmd.Parameters["@Inventory"].Value.ToString();
Item_6.Text = cmd.Parameters["@Number_Of_Recipients_Can"].Value.ToString();
Item_7.Text = cmd.Parameters["@Author"].Value.ToString();
Rtem_1.Text = cmd.Parameters["@Storage_Location"].Value.ToString();
MessageBox.Show("读取" + Material_Code +"档案成功!!","系统提醒",MessageBoxButtons.OK);
Flag = true;
}
else if((int)cmd.Parameters["@rs"].Value == 2)
{
MessageBox.Show("读取" + Material_Code + "档案信息出错!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
else if ((int)cmd.Parameters["@rs"].Value == 3)
{
MessageBox.Show("合计" + Material_Code + "领用数据出错!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
else if ((int)cmd.Parameters["@rs"].Value == 4)
{
MessageBox.Show("合计" + Material_Code + "退还数据出错!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
else if ((int)cmd.Parameters["@rs"].Value == 5)
{
MessageBox.Show("合计" + Material_Code + "库存总数数据出错!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
else if ((int)cmd.Parameters["@rs"].Value == 1)
{
MessageBox.Show("合计" + Material_Code + "档案信息出错!!", "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
Flag = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}
//读取出库其它值
public Boolean Get_Storage_Area_Other(TextBox Item_1,String TI_1, TextBox Item_2,String TI_2,TextBox Item_3,String TI_3,
PictureBox PItem,String TI_6)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
SqlDataReader srd = cmd.ExecuteReader();
while (srd.Read())
{
Item_1.Text = srd[TI_1].ToString();
Item_2.Text = srd[TI_2].ToString();
Item_3.Text = srd[TI_3].ToString();
//Item_4.Text = srd[TI_4].ToString();
//Item_5.Text = srd[TI_5].ToString();
byte[] ImageLogoArray=srd[TI_6] is DBNull?null:(byte[])(srd[TI_6]);
MemoryStream ms = null;
if (ImageLogoArray != null)
{
ms = new MemoryStream(ImageLogoArray);
PItem.Image = new Bitmap(ms);
}
}
Flag = true;
}
catch (Exception ex)
{
Flag = false;
MessageBox.Show(ex.ToString(), "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
sqlcon.Close();
}
return Flag;
}
//物品退还
public Boolean Return_Material_Files(String Product_Area, String Trademark, String Product_Name, String Type_Specification, String Technical_Parameters, String Material_Code,
String Return_One_Material, int Return_The_Number_Material, String Receiving_People, String Remark)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Product_Area", Product_Area);
cmd.Parameters.Add("@Trademark", Trademark);
cmd.Parameters.Add("@Product_Name", Product_Name);
cmd.Parameters.Add("@Type_Specification", Type_Specification);
cmd.Parameters.Add("@Technical_Parameters", Technical_Parameters);
cmd.Parameters.Add("@Material_Code", Material_Code);
cmd.Parameters.Add("@Return_One_Material", Return_One_Material);
cmd.Parameters.Add("@Return_The_Number_Material", Return_The_Number_Material);
cmd.Parameters.Add("@Receiving_People", Receiving_People);
cmd.Parameters.Add("@Remark", Remark);
cmd.Parameters.Add("@rs",1);
cmd.Parameters["@rs"].Direction = ParameterDirection.Output;
cmd.ExecuteScalar();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
Flag = true;
MessageBox.Show("退还记录录入成功!!", "系统提醒", MessageBoxButtons.OK);
}
else
{
Flag = false;
MessageBox.Show("退还记录录入失败!!","系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(),"系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}
//物品领用
public Boolean Receiving_Material_Files(String Product_Area, String Trademark, String Product_Name, String Type_Specification, String Technical_Parameters,
String Material_Code, String Recipient, int Picking_The_Number, String Sending_People, String Remark)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Product_Area", Product_Area);
cmd.Parameters.Add("@Trademark", Trademark);
cmd.Parameters.Add("@Product_Name", Product_Name);
cmd.Parameters.Add("@Type_Specification", Type_Specification);
cmd.Parameters.Add("@Technical_Parameters", Technical_Parameters);
cmd.Parameters.Add("@Material_Code", Material_Code);
cmd.Parameters.Add("@Recipient", Recipient);
cmd.Parameters.Add("@Picking_The_Number", Picking_The_Number);
cmd.Parameters.Add("@Sending_People", Sending_People);
cmd.Parameters.Add("@Remark", Remark);
cmd.Parameters.Add("@rs",1);
cmd.Parameters["@rs"].Direction = ParameterDirection.Output;
cmd.ExecuteScalar();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
Flag = true;
MessageBox.Show("领用记录录入完成!!","系统提醒",MessageBoxButtons.OK);
}
else
{
Flag = false;
MessageBox.Show("领用记录录入失败!!","系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(),"系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}
//读取物品存放区域或者品牌
public Boolean Get_Storage_Area(ComboBox C1,String Item)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
SqlDataReader srd = cmd.ExecuteReader();
while (srd.Read())
{
C1.Items.Add(srd[Item].ToString());
}
Flag = true;
}
catch (Exception ex)
{
Flag = false;
MessageBox.Show(ex.ToString(), "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
sqlcon.Close();
}
return Flag;
}
//出为更新记录
public Boolean Insert_Delivery_Record(String Operation_Status, String Product_Area, String Trademark, String Product_Name, String Type_Specification, String Technical_Parameters,
String Material_Code, int Quantity, String Author, String Remark)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Operation_Status", Operation_Status);
cmd.Parameters.Add("@Product_Area", Product_Area);
cmd.Parameters.Add("@Trademark", Trademark);
cmd.Parameters.Add("@Product_Name", Product_Name);
cmd.Parameters.Add("@Type_Specification", Type_Specification);
cmd.Parameters.Add("@Technical_Parameters", Technical_Parameters);
cmd.Parameters.Add("@Material_Code", Material_Code);
cmd.Parameters.Add("@Quantity", Quantity);
cmd.Parameters.Add("@Author", Author);
cmd.Parameters.Add("@Remark", Remark);
cmd.Parameters.Add("@rs",1);
cmd.Parameters["@rs"].Direction = ParameterDirection.Output;
cmd.ExecuteScalar();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
Flag = true;
}
else
{
MessageBox.Show("更新出库记录失败!!","系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(),"系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}
//出库更新库存
public Boolean Delivery_Of_Cargo_From_Storage(String Product_Area, String Trademark, String Product_Name, String Type_Specification, String Technical_Parameters,
String Material_Code, int Inventory, int The_Police_State,String Author)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure,sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Product_Area", Product_Area);
cmd.Parameters.Add("@Trademark", Trademark);
cmd.Parameters.Add("@Product_Name", Product_Name);
cmd.Parameters.Add("@Type_Specification",Type_Specification);
cmd.Parameters.Add("@Technical_Parameters", Technical_Parameters);
cmd.Parameters.Add("@Material_Code", Material_Code);
cmd.Parameters.Add("@Inventory", Inventory);
cmd.Parameters.Add("@The_Police_State", The_Police_State);
cmd.Parameters.Add("@Author", Author);
cmd.Parameters.Add("@rs",1);
cmd.Parameters["@rs"].Direction = ParameterDirection.Output;
cmd.ExecuteScalar();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
Flag = true;
MessageBox.Show("出库数据更新成功!!","系统提醒",MessageBoxButtons.OK);
}
else
{
MessageBox.Show("出库数据更新失败!!","系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(),"系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}
//添加或更新物品库存
public Boolean Insert_Update_Material_Control_List(String Product_Area, String Trademark, String Product_Name, String Type_Specification,
String Technical_Parameters, String Material_Code, int Inventory, int Safe_Stock, int The_Police_State, float Buying_Rrice, int Evaluate_Service_Life,
byte[] Product_Picture, String Author)
{
Boolean Flag = false;
SqlConnection sqlcon = new SqlConnection(this.Connection);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(this.Stored_Procedure, sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Product_Area", Product_Area);//产品使用区域
cmd.Parameters.Add("@Trademark", Trademark);//品牌
cmd.Parameters.Add("@Product_Name", Product_Name);//产品名称
cmd.Parameters.Add("@Type_Specification", Type_Specification);//型号规格
cmd.Parameters.Add("@Technical_Parameters", Technical_Parameters);//技术参数
cmd.Parameters.Add("@Material_Code", Material_Code);//物料代码
cmd.Parameters.Add("@Inventory", Inventory);//存货
cmd.Parameters.Add("@Safe_Stock", Safe_Stock);//安全库存
cmd.Parameters.Add("@The_Police_State", The_Police_State);//警界状态
cmd.Parameters.Add("@Buying_Rrice", Buying_Rrice);//购买价格
cmd.Parameters.Add("@Evaluate_Service_Life", Evaluate_Service_Life);//评估使用寿命
cmd.Parameters.Add("@Product_Picture", Product_Picture);//产品图片
cmd.Parameters.Add("@Author", Author);//作者
cmd.Parameters.Add("@rs",1);
cmd.Parameters["@rs"].Direction = ParameterDirection.Output;
cmd.ExecuteScalar();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
Flag = true;
MessageBox.Show("添加数据成功!!","系统提醒",MessageBoxButtons.OK);
}
else
{
Flag = false;
MessageBox.Show("添加数据失败!!","系统提醒",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
Flag = false;
MessageBox.Show(ex.ToString(), "系统提醒", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
sqlcon.Close();
}
return Flag;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
namespace Consumable_Control_System_V1._00
{
public partial class LOGIN : Form
{
public String User_Name ;
public int User_Grade = 0;
public int Option_Item = 0;//选择的项
public List<String> User_Info;
public LOGIN()
{
InitializeComponent();
}
private void LOGIN_FormClosing(object sender, FormClosingEventArgs e)//退出
{
System.Environment.Exit(1);
}
public void Create_Option_Windows()//创建主窗体线程
{
this.Hide();
Option_Windows MyWindows = new Option_Windows();
MyWindows.Show(this);
}
public void threadPro_Option_Windows()//创建线程
{
MethodInvoker MethInvo = new MethodInvoker(Create_Option_Windows);
BeginInvoke(MethInvo);
}
public void Set_Lable()
{
label5.Text = "";
label6.Text = "";
}
public Boolean RCompare_String(String CmpStr, int Index)//比较字符串
{
Boolean Flag = false;
foreach (String ss in this.User_Info)
{
String[] Array_Str = ss.Split(new String[] {","},StringSplitOptions.RemoveEmptyEntries);
if (Array_Str[Index] == CmpStr)
{
User_Name =Array_Str[2];
User_Grade =Convert.ToInt32(Array_Str[4]);
Flag = true;
return Flag;
}
}
return Flag;
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)//用户名
{
Set_Lable();
if (e.KeyChar == (Char)Keys.Enter)
{
if (textBox1.Text != String.Empty && textBox1.Text != null)
{
if (RCompare_String(textBox1.Text, 0))
{
textBox1.Enabled = false;
textBox2.Enabled = true;
textBox2.Focus();
}
else
{
label5.Text = "录入用户名错误!!";
textBox1.Focus();
textBox1.SelectAll();
}
}
else
{
label5.Text = "用户名信息不能为空!!";
textBox1.Focus();
textBox1.SelectAll();
}
}
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)//密码
{
Set_Lable();
if (e.KeyChar == (Char)Keys.Enter)
{
if (textBox2.Text != String.Empty && textBox2.Text != null)
{
if (RCompare_String(textBox2.Text, 1))
{
Thread Start_Option_Windows = new Thread(threadPro_Option_Windows);
Start_Option_Windows.Start();
}
else
{
label6.Text = "录入密码错误!!";
textBox2.Focus();
textBox2.SelectAll();
}
}
else
{
label6.Text = "密码信息不能为空!!";
textBox2.Focus();
textBox2.SelectAll();
}
}
}
private void LOGIN_Load(object sender, EventArgs e)
{
this.User_Info = new List<String>();
OperationDataBase Get_User_Info_Data = new OperationDataBase(@"SERVER2\SERVER2", "E_Material_Control", "sa", "adminsystem", "SELECT * FROM USER_Info_Table");
if (Get_User_Info_Data.Get_User_Info(this.User_Info))
{
textBox1.Enabled = true;
textBox1.Focus();
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Windows;
using System.Web;
using System.Collections;
using System.Data.OleDb;//读取Excel表内容
using System.Drawing;
using System.Reflection;
namespace Consumable_Control_System_V1._00
{
public partial class Option_Windows : Form
{
public String User_Name = "N/A";
public int User_Grade = 0;
public int Option_Item = 0;//选择的项
public Option_Windows()
{
InitializeComponent();
}
private void Option_Windows_Load(object sender, EventArgs e)
{
LOGIN ss = (LOGIN)this.Owner;
User_Name = ss.User_Name;
User_Grade = ss.User_Grade;
}
public void Set_Control_State(Control Item_1,Control Item_2,String Item1_Str,String Item2_Str)//设置控件状态
{
Item_1.Visible = true;
Item_1.Text = Item1_Str;
Item_2.Visible = true;
Item_2.Text = Item2_Str;
}
public void Set_Control_Visible_State(Control Item_1,Control Item_2)//设置控件显示状态
{
Item_1.Visible = false;
Item_2.Visible = false;
}
private void button7_Click(object sender, EventArgs e)//退出
{
System.Environment.Exit(0);
}
private void Option_Windows_FormClosing(object sender, FormClosingEventArgs e)//退出
{
System.Environment.Exit(0);
}
private void button1_Click(object sender, EventArgs e)//新增
{
Set_Control_State(label2,button8,"1.新增低耗或其它库物品表单.","添加(&A)");
Set_Control_Visible_State(label3,button9);
Option_Item = 1;
}
private void button2_Click(object sender, EventArgs e)//出库、入库
{
Set_Control_State(label2, button8, "1.低耗或其它库物品表单出库录入.", "出库(&D)");
Set_Control_State(label3, button9, "2.低耗或其它库物品表单入库录入.", "入库(&B)");
Option_Item = 2;
}
private void button3_Click(object sender, EventArgs e)//领用、退还
{
Set_Control_State(label2, button8, "1.低耗或其它库物品领用记录.", "领用(&R)");
Set_Control_State(label3, button9, "2.低耗或其它库物品退还记录.", "退不(&W)");
Option_Item = 3;
}
private void button4_Click(object sender, EventArgs e)//查询
{
Set_Control_State(label2, button8, "1.低耗或其它库物品表单查询.", "查询(&Q)");
Set_Control_Visible_State(label3, button9);
Option_Item = 4;
}
private void button5_Click(object sender, EventArgs e)//物品及耗材档案记录及查询
{
Set_Control_State(label2, button8, "1.低耗或其它库物品表单档案添加.", "添加(&A)");
Set_Control_State(label3, button9, "2.低耗或其它库物品表单档案查询.", "查询(&Q)");
Option_Item = 5;
}
private void button8_Click(object sender, EventArgs e)//控件1
{
Thread Button8_Start_Windows = new Thread(threadPro_Button8_Windows);
Button8_Start_Windows.Start();//启动窗体
}
public void Button8_Create_Win()//button_8创建线程窗体
{
this.Hide();
if (Option_Item==1)//新增
{
Add_NEW_Item MyWindows = new Add_NEW_Item();
MyWindows.Show(this);
}
else if (Option_Item == 2)//出库
{
Delivery_OfcargOfrom_Storage MyWindows = new Delivery_OfcargOfrom_Storage();
MyWindows.Show(this);
}
else if (Option_Item == 3)//领用
{
Picking MyWindows = new Picking();
MyWindows.Show(this);
}
else if (Option_Item == 4)//查询
{
Querying MyWindows = new Querying();
MyWindows.Show(this);
}
else if (Option_Item == 5)//档案添加
{
Item_Storage_File MyWindows = new Item_Storage_File();
MyWindows.Show(this);
}
}
public void threadPro_Button8_Windows()//button_8创建线程
{
MethodInvoker MethInvo = new MethodInvoker(Button8_Create_Win);
BeginInvoke(MethInvo);
}
private void button9_Click(object sender, EventArgs e)//控件2
{
Thread Button9_Start_Windows = new Thread(threadPro_Button9_Windows);
Button9_Start_Windows.Start();//启动线程
}
public void Button9_Create_Win()//button_8创建线程窗体
{
this.Hide();
if (Option_Item == 2)//入库
{
Be_Put_In_Storage MyWindows = new Be_Put_In_Storage();
MyWindows.Show(this);
}
else if (Option_Item == 3)//退还
{
Back_in MyWindows = new Back_in();
MyWindows.Show(this);
}
else if (Option_Item == 5)//档案查询
{
Querying_Item_Storage_File MyWindows = new Querying_Item_Storage_File();
MyWindows.Show(this);
}
}
public void threadPro_Button9_Windows()//button_9创建线程
{
MethodInvoker MethInvo = new MethodInvoker(Button9_Create_Win);
BeginInvoke(MethInvo);
}
}
}