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; using System.Data.SqlClient; using System.Configuration; namespace 药品信息管理系统 { public partial class frm_ClientTable : Form { public frm_ClientTable() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; dgv_Client.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv_Client.ColumnHeadersHeight = 30; dgv_Client.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Client.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 10, FontStyle.Bold); dgv_Client.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Client.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Client.ColumnHeadersDefaultCellStyle.ForeColor = ColorTranslator.FromHtml("#fff"); dgv_Client.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Client.GridColor = ColorTranslator.FromHtml("#006CB3"); dgv_Client.BackgroundColor = ColorTranslator.FromHtml("#E7F5FF"); dgv_Client.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Client.RowHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Client.RowTemplate.Height = 30; dgv_Client.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Client.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#97D5FF"); dgv_Client.AlternatingRowsDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#E1F3FF"); } private DataTable ClientTable; private void frm_ClientTable_Load(object sender, EventArgs e) { 管理员ToolStripMenuItem.Text = frm_LogIn.AdminName.ToString(); } private void btn_Load_Click(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "SELECT *,dbo.fn_GetPy(CName) AS pymc FROM tb_Client;"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; //DataTable ClientTable = new DataTable(); this.ClientTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(this.ClientTable ); sqlConnection.Close(); this.dgv_Client.Columns.Clear(); this.dgv_Client.DataSource = this.ClientTable; this.dgv_Client.Columns["CNo"].HeaderText = "客户编号"; this.dgv_Client.Columns["CName"].HeaderText = "客户名称"; this.dgv_Client.Columns["CAddress"].HeaderText = "地址"; this.dgv_Client.Columns["CTel"].HeaderText = "联系电话"; this.dgv_Client.Columns["sex"].HeaderText = "性别"; this.dgv_Client.Columns["RegistDate"].HeaderText = "注册时间"; this.dgv_Client.Columns["Birthday"].HeaderText = "出生日期"; this.dgv_Client.Columns["minsurance"].HeaderText = "是否医保"; this.dgv_Client.Columns["pymc"].Visible = false; this.dgv_Client.Columns["CName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Client.Columns[this.dgv_Client.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } private void btn_Submit_Click(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand insertCommand = new SqlCommand(); insertCommand.Connection = sqlConnection; insertCommand.CommandText = "insert tb_Client (CNo,CName,CTel,CAddress)values" + "(@CNo,@CName,@CTel,@CAddress)"; insertCommand.Parameters.Add("@CName", SqlDbType.VarChar, 0, "CName"); insertCommand.Parameters.Add("@CAddress", SqlDbType.VarChar, 0, "CAddress"); insertCommand.Parameters.Add("@CTel", SqlDbType.VarChar, 0, "CTel"); insertCommand.Parameters.Add("@CNo", SqlDbType.Char, 10, "CNo"); SqlCommand updateCommand = new SqlCommand(); updateCommand.Connection = sqlConnection; // updateCommand.CommandText = "UPDATE tb_Client" + " SET CNo=@NewCNo,CName=@CName,CAddress=@CAddress,CTel=@CTel" + " WHERE CNo=@OldCNo;"; updateCommand.Parameters.Add("@NewCNo", SqlDbType.Char, 10, "CNo"); updateCommand.Parameters.Add("@CName", SqlDbType.VarChar, 0, "CName"); // updateCommand.Parameters.Add("@CAddress", SqlDbType.VarChar, 0, "CAddress"); updateCommand.Parameters.Add("@CTel", SqlDbType.VarChar, 0, "CTel"); updateCommand.Parameters.Add("@OldCNo", SqlDbType.Char, 10, "CNo"); updateCommand.Parameters["@OldCNo"].SourceVersion = DataRowVersion.Original; SqlCommand deleteCommand = new SqlCommand(); deleteCommand.Connection = sqlConnection; deleteCommand.CommandText = "DELETE tb_Client" + " WHERE CNo=@CNo;"; deleteCommand.Parameters.Add("@CNo", SqlDbType.Char, 10, "CNo"); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.InsertCommand = insertCommand; sqlDataAdapter.UpdateCommand = updateCommand; sqlDataAdapter.DeleteCommand = deleteCommand; DataTable clientTable1 = (DataTable)this.dgv_Client .DataSource; sqlConnection.Open(); int rowAffected = sqlDataAdapter.Update(clientTable1); sqlConnection.Close(); MessageBox.Show("更新" + rowAffected.ToString() + "行。"); } } private void txx_Pinyin_TextChanged(object sender, EventArgs e) { if (dgv_Client.DataSource == null) { MessageBox.Show("请先点击“载入”载入客户数据"); txt_Pinyin.Text = ""; txt_Pinyin.Focus(); } else { DataRow[] searchResultRows = this.ClientTable.Select("pymc LIKE '%" + this.txt_Pinyin.Text.Trim() + "%'"); DataTable searchResultTable = this.ClientTable.Clone(); foreach (DataRow row in searchResultRows) { searchResultTable.ImportRow(row); } this.dgv_Client.DataSource = searchResultTable; } } private void dgv_Client_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void 联系我们ToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("致电谢雪妮:15060120822"); } private void 个人设置ToolStripMenuItem_Click(object sender, EventArgs e) { frm_FindPwd f = new frm_FindPwd(); f.ShowDialog(this); } } }
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; using System.Data.SqlClient; using System.Configuration; using System.Threading; namespace 药品信息管理系统 { public partial class frm_Content : Form { TreeNode xinxinode = new TreeNode(); TreeNode jinhuonode = new TreeNode(); TreeNode chuhuonode = new TreeNode(); TreeNode kucunnode = new TreeNode(); TreeNode tongjinode = new TreeNode(); TreeNode xitongnode = new TreeNode(); TreeNode xinxinode_Client = new TreeNode(); TreeNode xinxinode_Supply = new TreeNode(); TreeNode xinxinode_Medicine = new TreeNode(); TreeNode jinhuoNode_caigou = new TreeNode(); TreeNode jinhuoNode_jiesuan = new TreeNode(); TreeNode jinhuoNode_ruku = new TreeNode(); TreeNode chuhuoNode_yuji = new TreeNode(); TreeNode qijianNode_caigou = new TreeNode(); TreeNode jiduNode_caigou = new TreeNode(); TreeNode kucunNode_youxiaoqi = new TreeNode(); TreeNode kukunNode_kucun = new TreeNode(); TreeNode kucunNode_yaoku = new TreeNode(); public frm_Content() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; new Thread(() =>//利用线程实时刷新显示时间 { while (true) { try { lb_Time.BeginInvoke(new MethodInvoker(() => lb_Time.Text = DateTime.Now.ToString())); } catch { } Thread.Sleep(1000); } }) { IsBackground = true }.Start(); } private void frm_Content_Load(object sender, EventArgs e) { txt_Demo.SelectAll(); txt_Demo.Focus(); //将TextBox的AutoCompleteSource属性指定为CustomSource,也就是自定义数据源 this.txt_Demo.AutoCompleteSource = AutoCompleteSource.CustomSource; //设置自动搜索的模式,有好几种,可以分别研究一下,这里使用Suggest模式 this.txt_Demo.AutoCompleteMode = AutoCompleteMode.Suggest; //指定数据源 this.txt_Demo.AutoCompleteCustomSource.Add("客户指定管理"); this.txt_Demo.AutoCompleteCustomSource.Add("客户批量管理"); this.txt_Demo.AutoCompleteCustomSource.Add("供应商指定管理"); this.txt_Demo.AutoCompleteCustomSource.Add("供应商批量管理"); this.txt_Demo.AutoCompleteCustomSource.Add("药品指定管理"); this.txt_Demo.AutoCompleteCustomSource.Add("药品批量管理"); this.txt_Demo.AutoCompleteCustomSource.Add("药库管理"); this.txt_Demo.AutoCompleteCustomSource.Add("采购药品"); this.txt_Demo.AutoCompleteCustomSource.Add("结算订单"); this.txt_Demo.AutoCompleteCustomSource.Add("审核入库"); this.txt_Demo.AutoCompleteCustomSource.Add("出售药品"); this.txt_Demo.AutoCompleteCustomSource.Add("统计分析(期间)"); this.txt_Demo.AutoCompleteCustomSource.Add("统计分析(季度)"); this.txt_Demo.AutoCompleteCustomSource.Add("查询有效期"); this.txt_Demo.AutoCompleteCustomSource.Add("查询库存"); this.txt_Demo.AutoCompleteCustomSource.Add("查询退货记录"); this.txt_Demo.AutoCompleteCustomSource.Add("查询客户信息"); this.txt_Demo.AutoCompleteCustomSource.Add("查询供应商信息"); this.txt_Demo.AutoCompleteCustomSource.Add("查询药品信息"); this.txt_Demo.AutoCompleteCustomSource.Add("管理员修改密码"); this.txt_Demo.AutoCompleteCustomSource.Add("管理员注册"); this.txt_Demo.AutoCompleteCustomSource.Add("管理员个人中心"); this.txt_Demo.AutoCompleteCustomSource.Add("查询药库信息"); this.txt_Demo.AutoCompleteCustomSource.Add("查询采购订单(未结算)"); this.txt_Demo.AutoCompleteCustomSource.Add("查询采购订单(未入库)"); this.trv_Menu.SelectedNode = null; this.trv_Menu.ExpandAll(); //this.trv_Menu.SelectedNode = this.trv_Menu.Nodes[0]; //展开组件中的所有节点 //this.trv_Menu.SelectedNode.ExpandAll(); //this.trv_Menu.SelectedNode.Nodes .Add () //this.trv_Menu.Expanded = true; //this.trv_Menu.Nodes[1].Expand(); trv_Menu.LabelEdit = true;//可编辑状态。 //添加一个节点,这个结点是根节点。 xinxinode.Text = "信息维护"; xinxinode.Expand(); xinxinode.ImageIndex = 5; jinhuonode.Text = "进货管理"; jinhuonode.Expand(); jinhuonode.ImageIndex = 9; chuhuonode.Text = "出货管理"; chuhuonode.Expand(); chuhuonode.ImageIndex = 10; kucunnode.Text = "库存管理"; kucunnode.ImageIndex = 8; kucunnode.Expand(); tongjinode.Text = "采购统计"; tongjinode.ImageIndex = 3; xitongnode.Text = "系统设置"; xitongnode.ImageIndex = 7; //TreeNode node6 = new TreeNode(); //node6.Text = "库存管理"; trv_Menu.Nodes.Add(xinxinode); trv_Menu.Nodes.Add(jinhuonode); trv_Menu.Nodes.Add(chuhuonode); trv_Menu.Nodes.Add(kucunnode); trv_Menu.Nodes.Add(tongjinode); trv_Menu.Nodes.Add(xitongnode); //信息维护根节点下 xinxinode_Client.Text = "会员信息维护"; xinxinode_Client.ImageIndex = 2; xinxinode_Client.NodeFont = new Font("幼圆", 11); xinxinode_Supply.Text = "供应商信息维护"; xinxinode_Supply.ImageIndex = 1; xinxinode_Supply.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.Text = "药品信息维护"; xinxinode_Medicine.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.ImageIndex = 6; xinxinode.Nodes.Add(xinxinode_Client); xinxinode.Nodes.Add(xinxinode_Supply); xinxinode.Nodes.Add(xinxinode_Medicine); //进货管理根节点下 jinhuoNode_caigou.Text = "采集药品"; jinhuoNode_caigou.NodeFont = new Font("幼圆", 11); jinhuoNode_jiesuan.Text = "订单结算审核"; jinhuoNode_jiesuan.NodeFont = new Font("幼圆", 11); jinhuoNode_ruku.Text = "药品审核入库"; jinhuoNode_ruku.NodeFont = new Font("幼圆", 11); jinhuonode.Nodes.Add(jinhuoNode_caigou); jinhuonode.Nodes.Add(jinhuoNode_jiesuan); jinhuonode.Nodes.Add(jinhuoNode_ruku); //出货管理根节点下 chuhuoNode_yuji.Text = "出售药品"; chuhuoNode_yuji.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_shoukuan = new TreeNode(); //chuhuoNode_shoukuan.Text = "收款审核"; //chuhuoNode_shoukuan.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_chuku = new TreeNode(); //chuhuoNode_chuku.Text = "药品审核出库"; //chuhuoNode_chuku.NodeFont = new Font("幼圆", 11); chuhuonode.Nodes.Add(chuhuoNode_yuji); //chuhuonode.Nodes.Add(chuhuoNode_shoukuan); //chuhuonode.Nodes.Add(chuhuoNode_chuku); //统计管理根节点下 qijianNode_caigou.Text = "期间统计分析"; qijianNode_caigou.NodeFont = new Font("幼圆", 11); jiduNode_caigou.Text = "季度统计分析"; jiduNode_caigou.NodeFont = new Font("幼圆", 11); tongjinode.Nodes.Add(jiduNode_caigou); tongjinode.Nodes.Add(qijianNode_caigou); //库存管理根节点下 kucunNode_youxiaoqi.Text = "有效期提示"; kucunNode_youxiaoqi.NodeFont = new Font("幼圆", 11); kucunNode_youxiaoqi.ImageIndex = 4; kukunNode_kucun.Text = "库存量查询"; kukunNode_kucun.NodeFont = new Font("幼圆", 11); kucunNode_yaoku.Text = "药库管理"; kucunNode_yaoku.NodeFont = new Font("幼圆", 11); kucunnode.Nodes.Add(kucunNode_youxiaoqi); kucunnode.Nodes.Add(kukunNode_kucun); kucunnode.Nodes.Add(kucunNode_yaoku); //this.trv_Menu.CheckBoxes = true; this.trv_Menu.ExpandAll(); 管理员ToolStripMenuItem.Text = frm_LogIn.AdminName.ToString(); int dt=Convert .ToInt32 (DateTime.Now.Hour .ToString () ) ; if (dt >= 0 && dt <= 6) { lb_Admin.Text = "凌晨好!" + frm_LogIn.AdminName.ToString(); } if (dt >6 && dt <=12) { lb_Admin.Text = "早上好!" + frm_LogIn.AdminName.ToString(); } if (dt >12 && dt <=14) { lb_Admin.Text = "中午好!" + frm_LogIn.AdminName.ToString(); } if (dt >14 && dt <= 18) { lb_Admin.Text = "下午好!" + frm_LogIn.AdminName.ToString(); } if (dt >18 && dt <= 24) { lb_Admin.Text = "晚上好!" + frm_LogIn.AdminName.ToString(); } //txt_Time.Text = DateTime.Now.ToString(); // TODO: 这行代码将数据加载到表“medicineDataSet.tb_Client”中。您可以根据需要移动或移除它。 } private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { } private void btn_ClientManage_Click(object sender, EventArgs e) { frm_Client frm_client = new frm_Client(); frm_client.ShowDialog(this); } private void btn_seek_Click(object sender, EventArgs e) { } private void btn_Add_Click(object sender, EventArgs e) { } private void btn_seekName_Click(object sender, EventArgs e) { } //未完成 private void btn_alter_Click(object sender, EventArgs e) { } private void btn_Delete_Click(object sender, EventArgs e) { } private void btn_xiaoshou_Click(object sender, EventArgs e) { medicine _medicine = new medicine(); _medicine.ShowDialog(this); } private void btn_caigou_Click(object sender, EventArgs e) { frm_Supply frm_supply = new frm_Supply(); frm_supply.ShowDialog(this); } private void gb_supply_Enter(object sender, EventArgs e) { } private void btn_chaxun_Click(object sender, EventArgs e) { frm_seek frm__seek = new frm_seek(); frm__seek.ShowDialog(this); } private void tuToolStripMenuItem_Click(object sender, EventArgs e) { frm_LogIn frm_logIn = new frm_LogIn(); frm_logIn.ShowDialog(this); } private void btn_Stock_Click(object sender, EventArgs e) { frm_Stock frm_stock = new frm_Stock(); frm_stock.ShowDialog(this); } private void button1_Click(object sender, EventArgs e) { frm_caigou frm__caigou = new frm_caigou(); frm__caigou.ShowDialog(this); } private void button2_Click(object sender, EventArgs e) { frm_chushou frm__chushou = new frm_chushou(); frm__chushou.ShowDialog(this); } private void button4_Click(object sender, EventArgs e) { frm_Analysis frm_analysis = new frm_Analysis(); frm_analysis.ShowDialog(this); } private void btn_Order_Click(object sender, EventArgs e) { } private void button3_Click(object sender, EventArgs e) { } private void 退出账户ToolStripMenuItem_Click(object sender, EventArgs e) { personnel p = new personnel(); p.ShowDialog(this); } private void 修改密码_Click(object sender, EventArgs e) { frm_FindPwd f = new frm_FindPwd(); f.ShowDialog(this); } private void lianxiToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("致电谢雪妮:15060120822"); } private void lb_Time_Click(object sender, EventArgs e) { } private void trv_Menu_AfterSelect(object sender, TreeViewEventArgs e) { if (this.trv_Menu.SelectedNode == xinxinode_Client) { frm_Client f = new frm_Client(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Supply) { frm_Supply f = new frm_Supply(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Medicine) { medicine f = new medicine(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_caigou) { frm_caigou f = new frm_caigou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_jiesuan) { frm_caigouOrder f = new frm_caigouOrder(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_ruku) { frm_caigouStored f = new frm_caigouStored(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == chuhuoNode_yuji) { frm_chushou f = new frm_chushou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == qijianNode_caigou) { frm_Analysis_qijian f = new frm_Analysis_qijian(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jiduNode_caigou ) { frm_Analysis f = new frm_Analysis(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_youxiaoqi) { frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kukunNode_kucun) { frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_yaoku ) { frm_Stock f = new frm_Stock(); f.ShowDialog(this); } } private void 退出登录ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("确认退出本系统?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Application.Exit(); } } private void 退出登录ToolStripMenuItem1_Click(object sender, EventArgs e) { this.Hide(); frm_LogIn f = new frm_LogIn(); f.ShowDialog(this); } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void txt_Demo_TextChanged(object sender, EventArgs e) { if (txt_Demo.Text == "客户指定管理" || txt_Demo.Text == "查询客户信息") { frm_Client f = new frm_Client(); f.ShowDialog(this); } if (txt_Demo.Text == "客户批量管理") { frm_ClientTable f = new frm_ClientTable(); f.ShowDialog(this); } if (txt_Demo.Text == "供应商指定管理" || txt_Demo.Text == "查询供应商信息") { frm_Supply f = new frm_Supply(); f.ShowDialog(this); } if (txt_Demo.Text == "供应商批量管理") { frm_SupplyTable f = new frm_SupplyTable(); f.ShowDialog(this); } if (txt_Demo.Text == "药品指定管理" || txt_Demo .Text =="查询药品信息") { medicine f = new medicine(); f.ShowDialog(this); } if (txt_Demo.Text == "药品批量管理") { frm_MedicineTable f = new frm_MedicineTable(); f.ShowDialog(this); } if (txt_Demo.Text == "药库管理" || txt_Demo .Text =="查询药库信息") { frm_Stock f = new frm_Stock(); f.ShowDialog(this); } if (txt_Demo.Text == "查询有效期") { frm_seek f=new frm_seek (); f.ShowDialog(this); } if (txt_Demo.Text == "查询库存") { frm_seek f = new frm_seek(); f.ShowDialog(this); } if (txt_Demo.Text == "采购药品") { frm_caigou f = new frm_caigou(); f.ShowDialog(this); } if (txt_Demo.Text == "统计分析(期间)") { frm_Analysis_qijian f = new frm_Analysis_qijian(); f.ShowDialog(this); } if (txt_Demo.Text == "统计分析(季度)") { frm_Analysis f = new frm_Analysis(); f.ShowDialog(this); } if (txt_Demo.Text == "审核入库" || txt_Demo.Text == "查询采购订单(未入库)") { frm_caigouStored f = new frm_caigouStored(); f.ShowDialog(this); } if (txt_Demo.Text == "订单结算" || txt_Demo.Text == "查询采购订单(未结算)") { frm_caigouOrder f = new frm_caigouOrder(); f.ShowDialog(this); } if (txt_Demo.Text == "出售药品") { frm_chushou f = new frm_chushou(); f.ShowDialog(this); } if (txt_Demo.Text == "查询退货记录") { frm_ReturnHistory f = new frm_ReturnHistory(); f.ShowDialog(this); } if (txt_Demo.Text == "管理员修改密码") { frm_FindPwd f = new frm_FindPwd(); f.ShowDialog(this); } if (txt_Demo.Text == "管理员注册") { frm_Register f = new frm_Register(); f.ShowDialog(this); } if (txt_Demo.Text == "管理员个人中心") { personnel f = new personnel(); f.ShowDialog(this); } } } }
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; using System.Data.SqlClient; using System.Configuration; namespace 药品信息管理系统 { public partial class frm_MedicineTable : Form { private DataTable medicineTable; private DataTable SupplyTable; private DataTable StockTable; private DataView CurrentPageView; private int PageSize; private int CurrentPageNo; private int MaxPageNo; public frm_MedicineTable() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; //本窗体启动位置设为屏幕中央; this.dgv_Medicine.AllowUserToAddRows = true ; //数据网格视图不允许用户添加行; this.dgv_Medicine.RowHeadersVisible = true ; //数据网格视图的行标题不可见; this.dgv_Medicine.BackgroundColor = Color.White; //数据网格视图的背景色设为白色; this.dgv_Medicine.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Medicine.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv_Medicine.ColumnHeadersHeight = 30; dgv_Medicine.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Medicine.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 10, FontStyle.Bold); dgv_Medicine.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Medicine.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Medicine.ColumnHeadersDefaultCellStyle.ForeColor = ColorTranslator.FromHtml("#fff"); dgv_Medicine.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Medicine.GridColor = ColorTranslator.FromHtml("#006CB3"); dgv_Medicine.BackgroundColor = ColorTranslator.FromHtml("#E7F5FF"); dgv_Medicine.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Medicine.RowHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Medicine.RowTemplate.Height = 30; dgv_Medicine.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Medicine.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#97D5FF"); dgv_Medicine.AlternatingRowsDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#E1F3FF"); } private void frm_MedicineTable_Load(object sender, EventArgs e) { //label1.Text = "当前页码为" + CurrentPageNo.ToString(); 管理员ToolStripMenuItem.Text = frm_LogIn.AdminName.ToString(); } private void btn_Load_Click(object sender, EventArgs e) { this.PageSize = 8; this.CurrentPageNo = 1; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); SqlCommand sqlcommand1 = new SqlCommand(); SqlCommand sqlCommand2 = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlcommand1.Connection = sqlConnection; sqlCommand2.Connection = sqlConnection; sqlCommand.CommandText = "SELECT * FROM tb_Supply;"; sqlcommand1.CommandText = "SELECT * FROM Tb_Stock"; sqlCommand2.CommandText = "SELECT *,dbo.fn_GetPy(MName) AS pymc FROM tb_medicine where 1=0;"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; this.SupplyTable = new DataTable(); SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); sqlDataAdapter1.SelectCommand = sqlcommand1; this.StockTable = new DataTable(); SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); sqlDataAdapter2.SelectCommand = sqlCommand2; this.medicineTable = new DataTable(); this.medicineTable.TableName = "medicine"; sqlConnection.Open(); sqlDataAdapter.Fill(this.SupplyTable ); sqlDataAdapter1.Fill(this.StockTable ); sqlDataAdapter2.Fill(this.medicineTable ); DataColumn rowIdColumn = new DataColumn(); rowIdColumn.ColumnName = "RowID"; rowIdColumn.DataType = typeof(int); rowIdColumn.AutoIncrement = true; rowIdColumn.AutoIncrementSeed = 1; rowIdColumn.AutoIncrementStep = 1; this.medicineTable.Columns.Add(rowIdColumn); sqlCommand2.CommandText = "SELECT *,dbo.fn_GetPy(MName) AS pymc FROM tb_medicine;"; sqlDataAdapter2.SelectCommand = sqlCommand2; sqlDataAdapter2.Fill(this.medicineTable); sqlConnection.Close(); this.MaxPageNo = this.medicineTable.Rows.Count / this.PageSize + 1; //label1.Text = this.MaxPageNo.ToString(); ; this.CurrentPageView = new DataView(); this.CurrentPageView.Table = this.medicineTable; this.CurrentPageView.Sort = "RowID ASC"; this.CurrentPageView.RowFilter ="RowID >" + (this.CurrentPageNo - 1) * this.PageSize +" AND RowID <=" + this.CurrentPageNo * this.PageSize; this.dgv_Medicine.Columns.Clear(); this.dgv_Medicine.DataSource = this.CurrentPageView ; this.dgv_Medicine.Columns["MNo"].Visible = false; this.dgv_Medicine.Columns["MName"].HeaderText = "药品名称"; //this.dgv_Medicine.Columns["MNum"].HeaderText = "库存"; this.dgv_Medicine.Columns["Norm"].HeaderText = "规格"; this.dgv_Medicine.Columns["MPrice"].HeaderText = "单价"; this.dgv_Medicine.Columns["ValidDate"].HeaderText = "有效期至"; this.dgv_Medicine.Columns["IsOTC"].HeaderText = "是否为非处方药"; this.dgv_Medicine.Columns["Instuction"].Visible = false; this.dgv_Medicine.Columns["SupplyNo"].Visible = false; this.dgv_Medicine.Columns["StockNo"].Visible = false; this.dgv_Medicine.Columns["Photo"].Visible = false; this.dgv_Medicine.Columns["pymc"].Visible = false; this.dgv_Medicine.Columns["MNum"].Visible = false; this.dgv_Medicine.Columns["RowID"].Visible = false; //将数据网格视图的指定列设为不可见; //this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = // DataGridViewAutoSizeColumnMode.Fill; DataGridViewComboBoxColumn SupplyColumn = new DataGridViewComboBoxColumn(); SupplyColumn.Name = "SupplyName"; SupplyColumn.HeaderText = "供应商"; SupplyColumn.DataSource = this.SupplyTable ; SupplyColumn.DisplayMember = "SupplyName"; SupplyColumn.ValueMember = "SupplyNo"; SupplyColumn.DataPropertyName = "SupplyNo"; SupplyColumn.DisplayIndex = 12; SupplyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Medicine.Columns.Add(SupplyColumn); DataGridViewComboBoxColumn StockColumn = new DataGridViewComboBoxColumn(); StockColumn.Name = "StockName"; StockColumn.HeaderText = "药库"; StockColumn.DataSource = this.StockTable ; StockColumn.DisplayMember = "StockName"; StockColumn.ValueMember = "StockNo"; StockColumn.DataPropertyName = "StockNo"; StockColumn.DisplayIndex = 13; StockColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Medicine.Columns.Add(StockColumn); this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } private void btn_Submit_Click(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand insertCommand = new SqlCommand(); insertCommand.Connection = sqlConnection; insertCommand.CommandText = "insert tb_medicine " + " (MNo,MName,IsOTC,MNum,Norm,MPrice,ValidDate,SupplyNo,StockNo) " + " values (@MNo,@MName,@IsOTC,@MNum,@Norm,@MPrice,@ValidDate,@SupplyNo,@StockNo);"; insertCommand.Parameters.Add("@MName", SqlDbType.VarChar, 0, "MName"); insertCommand.Parameters.Add("@IsOTC", SqlDbType.Bit, 0, "IsOTC"); insertCommand.Parameters.Add("@MNum", SqlDbType.VarChar, 0, "MNum"); insertCommand.Parameters.Add("@Norm", SqlDbType.VarChar, 10, "Norm"); insertCommand.Parameters.Add("@MPrice", SqlDbType.Money, 0, "MPrice"); insertCommand.Parameters.Add("@ValidDate", SqlDbType.Date, 0, "ValidDate"); insertCommand.Parameters.Add("@SupplyNo", SqlDbType.Char, 10, "SupplyNo"); insertCommand.Parameters.Add("@StockNo", SqlDbType.Char, 10, "StockNo"); insertCommand.Parameters.Add("@MNo", SqlDbType.Char, 10, "MNo"); SqlCommand updateCommand = new SqlCommand(); updateCommand.Connection = sqlConnection; updateCommand.CommandText = "UPDATE tb_medicine" + " SET MNo=@NewMNo,MName=@MName,IsOTC=@IsOTC,MNum=@MNum,Norm=@Norm,MPrice=@MPrice,ValidDate=@ValidDate,SupplyNo=@SupplyNo,StockNo=@StockNo" + " WHERE MNo=@OldMNo;"; updateCommand.Parameters.Add("@NewMNo", SqlDbType.Char, 10, "MNo"); updateCommand.Parameters.Add("@MName", SqlDbType.VarChar, 0, "MName"); updateCommand.Parameters.Add("@IsOTC", SqlDbType.Bit, 0, "IsOTC"); updateCommand.Parameters.Add("@MNum", SqlDbType.VarChar, 0, "MNum"); updateCommand.Parameters.Add("@Norm", SqlDbType.VarChar, 0, "Norm"); updateCommand.Parameters.Add("@MPrice", SqlDbType.Money, 0, "MPrice"); updateCommand.Parameters.Add("@ValidDate", SqlDbType.Date, 0, "ValidDate"); updateCommand.Parameters.Add("@SupplyNo", SqlDbType.Char, 10, "SupplyNo"); updateCommand.Parameters.Add("@StockNo", SqlDbType.Char, 10, "StockNo"); updateCommand.Parameters.Add("@OldMNo", SqlDbType.Char, 10, "MNo"); updateCommand.Parameters["@OldMNo"].SourceVersion = DataRowVersion.Original; SqlCommand deleteCommand = new SqlCommand(); deleteCommand.Connection = sqlConnection; deleteCommand.CommandText = "Delete tb_medicine" + " WHERE MNo=@MNo;"; deleteCommand.Parameters.Add("@MNo", SqlDbType.Char, 10, "MNo"); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.InsertCommand = insertCommand; sqlDataAdapter.UpdateCommand = updateCommand; sqlDataAdapter.DeleteCommand = deleteCommand; this.CurrentPageView=(DataView)this.dgv_Medicine.DataSource ; //this.medicineTable= this.dgv_Medicine .DataSource ; sqlConnection.Open(); int rowAffected = sqlDataAdapter.Update(this.medicineTable); sqlConnection.Close(); MessageBox.Show("更新" + rowAffected.ToString() + "行。"); } } private void txt_Pinyin_TextChanged(object sender, EventArgs e) { if (dgv_Medicine.DataSource == null) { MessageBox.Show("请先点击“载入”载入药品数据"); txt_Pinyin.Text = ""; txt_Pinyin.Focus(); } else { DataRow[] searchResultRows = this.medicineTable.Select("pymc LIKE '%" + this.txt_Pinyin.Text.Trim() + "%'"); DataTable searchResultTable = this.medicineTable.Clone(); foreach (DataRow row in searchResultRows) { searchResultTable.ImportRow(row); } this.dgv_Medicine.DataSource = searchResultTable; } } private void btn_PreviosPage_Click(object sender, EventArgs e) { if (this.CurrentPageNo > 1) { this.CurrentPageNo--; } this.CurrentPageView.RowFilter = "RowID >" + (this.CurrentPageNo - 1) * this.PageSize + " AND RowID <=" + this.CurrentPageNo * this.PageSize; } private void btn_NextPage_Click(object sender, EventArgs e) { if (this.CurrentPageNo < this.MaxPageNo) { this.CurrentPageNo++; } this.CurrentPageView.RowFilter = "RowID >" + (this.CurrentPageNo - 1) * this.PageSize + " AND RowID <=" + this.CurrentPageNo * this.PageSize; } private void ln_formName_Click(object sender, EventArgs e) { } private void label1_Click(object sender, EventArgs e) { } private void 联系我们ToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("致电谢雪妮:15060120822"); } private void 个人设置ToolStripMenuItem_Click(object sender, EventArgs e) { frm_FindPwd f = new frm_FindPwd(); f.ShowDialog(this); } } }
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; using System.Data.SqlClient; using System.Configuration; namespace 药品信息管理系统 { public partial class frm_ReturnHistory : Form { private DataTable StoredTable; public frm_ReturnHistory() { this.StartPosition = FormStartPosition.CenterScreen; InitializeComponent(); dgv_Medicine.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv_Medicine.ColumnHeadersHeight = 30; dgv_Medicine.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dgv_Medicine.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 10, FontStyle.Bold); dgv_Medicine.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Medicine.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Medicine.ColumnHeadersDefaultCellStyle.ForeColor = ColorTranslator.FromHtml("#fff"); dgv_Medicine.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Medicine.GridColor = ColorTranslator.FromHtml("#006CB3"); dgv_Medicine.BackgroundColor = ColorTranslator.FromHtml("#E7F5FF"); dgv_Medicine.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Medicine.RowHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Medicine.RowTemplate.Height = 30; dgv_Medicine.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Medicine.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#97D5FF"); dgv_Medicine.AlternatingRowsDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#E1F3FF"); } private void frm_ReturnHistory_Load(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "select s.caigouNo,s.caigouDate,s.PaidDate,ss.SupplyName,t.AName,s.PaidAdmin,m.MNo,m.MName,s.num,s.isPaid,isReturn from tb_SelectMedicineBySupply as s join tb_medicine as m on m.MNo =s.MNo join tb_Supply as ss on ss.SupplyNo=s.SupplyNo join tb_Admin as t on t.ANo=s.ANo where s.isPaid=1 and isReturn=1"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; //DataTable ClientTable = new DataTable(); this.StoredTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(this.StoredTable); sqlConnection.Close(); this.dgv_Medicine.Columns.Clear(); this.dgv_Medicine.DataSource = this.StoredTable; this.dgv_Medicine.Columns["caigouDate"].HeaderText = "采购日期"; this.dgv_Medicine.Columns["caigouDate"].ReadOnly = true; this.dgv_Medicine.Columns["SupplyName"].HeaderText = "供应商"; this.dgv_Medicine.Columns["caigouNo"].HeaderText = "流水号"; this.dgv_Medicine.Columns["MName"].HeaderText = "药品名称"; this.dgv_Medicine.Columns["num"].HeaderText = "药品数量"; this.dgv_Medicine.Columns["PaidAdmin"].HeaderText = "结算员"; this.dgv_Medicine.Columns["MNo"].HeaderText = "药品编号"; //this.dgv_Client.Columns["pinyin"].Visible = false; this.dgv_Medicine.Columns["PaidDate"].HeaderText = "结算日期"; this.dgv_Medicine.Columns["isPaid"].HeaderText = "付款状态"; this.dgv_Medicine.Columns["AName"].HeaderText = "采购员"; this.dgv_Medicine.Columns["isReturn"].HeaderText = "是否退货"; //dgv_Medicine.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //this.dgv_Medicine.Columns["CName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } } }
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; using System.Data.SqlClient; using System.Configuration; using System.Drawing.Printing; namespace 药品信息管理系统 { public partial class frm_seek : Form { TreeNode xinxinode = new TreeNode(); TreeNode jinhuonode = new TreeNode(); TreeNode chuhuonode = new TreeNode(); TreeNode kucunnode = new TreeNode(); TreeNode tongjinode = new TreeNode(); TreeNode xitongnode = new TreeNode(); TreeNode xinxinode_Client = new TreeNode(); TreeNode xinxinode_Supply = new TreeNode(); TreeNode xinxinode_Medicine = new TreeNode(); TreeNode jinhuoNode_caigou = new TreeNode(); TreeNode jinhuoNode_jiesuan = new TreeNode(); TreeNode jinhuoNode_ruku = new TreeNode(); TreeNode chuhuoNode_yuji = new TreeNode(); TreeNode qijianNode_caigou = new TreeNode(); TreeNode jiduNode_caigou = new TreeNode(); TreeNode kucunNode_youxiaoqi = new TreeNode(); TreeNode kukunNode_kucun = new TreeNode(); TreeNode kucunNode_yaoku = new TreeNode(); private DataTable medicineTable; private DataTable SupplyTable; private DataTable StockTable; //private Label label = new Label(); public String MName; public String Stock; public String he; public string text; private bool flag=false ; public frm_seek() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; this.dgv_Date.AllowUserToAddRows = false ; this.dgv_Date.RowHeadersVisible = false ; this.dgv_Date.BackgroundColor = Color.White; this.dgv_Date.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Date.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv_Date.ColumnHeadersHeight = 30; dgv_Date.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Date.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 10, FontStyle.Bold); dgv_Date.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Date.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Date.ColumnHeadersDefaultCellStyle.ForeColor = ColorTranslator.FromHtml("#fff"); dgv_Date.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Date.GridColor = ColorTranslator.FromHtml("#006CB3"); dgv_Date.BackgroundColor = ColorTranslator.FromHtml("#E7F5FF"); dgv_Date.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Date.RowHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Date.RowTemplate.Height = 30; dgv_Date.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Date.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#97D5FF"); dgv_Date.AlternatingRowsDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#E1F3FF"); } //private DataTable SupplyTable; //private DataTable StockTable; //private DataTable medicineTable; PointF p; Font f = new Font("宋体", 15); Color c = Color.White; string temp; private void frm_seek_Load(object sender, EventArgs e) { this.trv_Menu.BackColor = Color.AliceBlue; this.trv_Menu.SelectedNode = null; this.trv_Menu.ExpandAll(); //this.trv_Menu.SelectedNode = this.trv_Menu.Nodes[0]; //展开组件中的所有节点 //this.trv_Menu.SelectedNode.ExpandAll(); //this.trv_Menu.SelectedNode.Nodes .Add () //this.trv_Menu.Expanded = true; //this.trv_Menu.Nodes[1].Expand(); trv_Menu.LabelEdit = true;//可编辑状态。 //添加一个节点,这个结点是根节点。 xinxinode.Text = "信息维护"; xinxinode.Expand(); xinxinode.ImageIndex = 5; jinhuonode.Text = "进货管理"; jinhuonode.Expand(); jinhuonode.ImageIndex = 9; chuhuonode.Text = "出货管理"; chuhuonode.Expand(); chuhuonode.ImageIndex = 10; kucunnode.Text = "库存管理"; kucunnode.ImageIndex = 8; kucunnode.Expand(); tongjinode.Text = "采购统计"; tongjinode.ImageIndex = 3; xitongnode.Text = "系统设置"; xitongnode.ImageIndex = 7; //TreeNode node6 = new TreeNode(); //node6.Text = "库存管理"; trv_Menu.Nodes.Add(xinxinode); trv_Menu.Nodes.Add(jinhuonode); trv_Menu.Nodes.Add(chuhuonode); trv_Menu.Nodes.Add(kucunnode); trv_Menu.Nodes.Add(tongjinode); trv_Menu.Nodes.Add(xitongnode); //信息维护根节点下 xinxinode_Client.Text = "会员信息维护"; xinxinode_Client.ImageIndex = 2; xinxinode_Client.NodeFont = new Font("幼圆", 11); xinxinode_Supply.Text = "供应商信息维护"; xinxinode_Supply.ImageIndex = 1; xinxinode_Supply.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.Text = "药品信息维护"; xinxinode_Medicine.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.ImageIndex = 6; xinxinode.Nodes.Add(xinxinode_Client); xinxinode.Nodes.Add(xinxinode_Supply); xinxinode.Nodes.Add(xinxinode_Medicine); //进货管理根节点下 jinhuoNode_caigou.Text = "采集药品"; jinhuoNode_caigou.NodeFont = new Font("幼圆", 11); jinhuoNode_jiesuan.Text = "订单结算审核"; jinhuoNode_jiesuan.NodeFont = new Font("幼圆", 11); jinhuoNode_ruku.Text = "药品审核入库"; jinhuoNode_ruku.NodeFont = new Font("幼圆", 11); jinhuonode.Nodes.Add(jinhuoNode_caigou); jinhuonode.Nodes.Add(jinhuoNode_jiesuan); jinhuonode.Nodes.Add(jinhuoNode_ruku); //出货管理根节点下 chuhuoNode_yuji.Text = "出售药品"; chuhuoNode_yuji.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_shoukuan = new TreeNode(); //chuhuoNode_shoukuan.Text = "收款审核"; //chuhuoNode_shoukuan.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_chuku = new TreeNode(); //chuhuoNode_chuku.Text = "药品审核出库"; //chuhuoNode_chuku.NodeFont = new Font("幼圆", 11); chuhuonode.Nodes.Add(chuhuoNode_yuji); //chuhuonode.Nodes.Add(chuhuoNode_shoukuan); //chuhuonode.Nodes.Add(chuhuoNode_chuku); //统计管理根节点下 qijianNode_caigou.Text = "期间统计分析"; qijianNode_caigou.NodeFont = new Font("幼圆", 11); jiduNode_caigou.Text = "季度统计分析"; jiduNode_caigou.NodeFont = new Font("幼圆", 11); tongjinode.Nodes.Add(jiduNode_caigou); tongjinode.Nodes.Add(qijianNode_caigou); //库存管理根节点下 kucunNode_youxiaoqi.Text = "有效期提示"; kucunNode_youxiaoqi.NodeFont = new Font("幼圆", 11); kucunNode_youxiaoqi.ImageIndex = 4; kucunNode_youxiaoqi.BackColor = Color.Red; kukunNode_kucun.Text = "库存量查询"; kukunNode_kucun.NodeFont = new Font("幼圆", 11); kukunNode_kucun.BackColor = Color.Red; kucunNode_yaoku.Text = "药库管理"; kucunNode_yaoku.NodeFont = new Font("幼圆", 11); kucunnode.Nodes.Add(kucunNode_youxiaoqi); kucunnode.Nodes.Add(kukunNode_kucun); kucunnode.Nodes.Add(kucunNode_yaoku); //this.trv_Menu.CheckBoxes = true; this.trv_Menu.ExpandAll(); //this.label.Location = new Point(10, 436); //this.label.BackColor = Color.Transparent; //this.label.Size = new Size(1000, 30); this.Controls.Add(lb_message ); //this.label.Text = ""; this.timer1.Enabled = true; this.timer1.Interval = 200; p = new PointF(this.lb_message .Size.Width, 0); 管理员ToolStripMenuItem.Text = frm_LogIn.AdminName.ToString(); using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlcommand = new SqlCommand(); sqlcommand.Connection = sqlConnection; sqlcommand.CommandText = "select m.MNo,m.MName,m.MNum,m.Norm,m.MPrice,m.ValidDate,s.StockName from tb_Medicine as m join tb_Stock as s on s.StockNo=m.StockNo where DATEDIFF(Day, getdate(),m.ValidDate) <1"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlcommand; DataTable Table = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(Table); sqlConnection.Close(); this.dgv_Date.Columns.Clear(); this.dgv_Date.DataSource = Table; this.dgv_Date.Columns["MNo"].HeaderText = "药品编号"; this.dgv_Date.Columns["MName"].HeaderText = "药品名称"; this.dgv_Date.Columns["MNum"].HeaderText = "库存"; this.dgv_Date.Columns["Norm"].HeaderText = "规格"; this.dgv_Date.Columns["MPrice"].HeaderText = "单价"; this.dgv_Date.Columns["ValidDate"].HeaderText = "有效期至"; this.dgv_Date.Columns["StockName"].HeaderText = "所在药库"; //this.dgv_Date.Columns["Photo"].Visible = false; for (int i = 0; i < this.dgv_Date.RowCount; i++) { this.MName = this.dgv_Date.Rows[i].Cells[1].Value.ToString(); this.Stock = this.dgv_Date.Rows[i].Cells[6].Value.ToString(); this.he = this.Stock + "的" + this.MName + "过期了噢!"; this.text += he + " "; this.dgv_Date.Rows[i].Cells[5].Style.ForeColor = Color.Red; } this.dgv_Date.Columns[this.dgv_Date.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } private void btn_Load_Click(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlcommand1 = new SqlCommand(); SqlCommand sqlCommand2 = new SqlCommand(); sqlcommand1.Connection = sqlConnection; sqlCommand2.Connection = sqlConnection; sqlcommand1.CommandText = "SELECT * FROM Tb_Stock"; sqlCommand2.CommandText = " select * from tb_medicine as m where DATEDIFF(month, getdate(),m.ValidDate) <" + this.nud_Month.Value + ""; SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); sqlDataAdapter1.SelectCommand = sqlcommand1; DataTable StockTable = new DataTable(); SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); sqlDataAdapter2.SelectCommand = sqlCommand2; DataTable medicineTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter1.Fill(StockTable); sqlDataAdapter2.Fill(medicineTable); sqlConnection.Close(); this.dgv_Date.Columns.Clear(); this.dgv_Date.DataSource = medicineTable; this.dgv_Date.Columns["MNo"].Visible = false; this.dgv_Date.Columns["MName"].HeaderText = "药品名称"; this.dgv_Date.Columns["MNum"].HeaderText = "库存"; this.dgv_Date.Columns["Norm"].HeaderText = "规格"; this.dgv_Date.Columns["MPrice"].HeaderText = "单价"; this.dgv_Date.Columns["ValidDate"].HeaderText = "有效期至"; //this.dgv_Date.Columns["v"].HeaderText = "距离过期还剩 _月"; this.dgv_Date.Columns["IsOTC"].HeaderText = "是否为非处方药"; this.dgv_Date.Columns["Instuction"].Visible = false; this.dgv_Date.Columns["SupplyNo"].Visible = false; this.dgv_Date.Columns["StockNo"].Visible = false; this.dgv_Date.Columns["Photo"].Visible = false; //this.dgv_Date.Columns["pinyin"].Visible = false; DataGridViewComboBoxColumn StockColumn = new DataGridViewComboBoxColumn(); StockColumn.Name = "StockName"; StockColumn.HeaderText = "所在药库"; StockColumn.DataSource = StockTable; StockColumn.DisplayMember = "StockName"; StockColumn.ValueMember = "StockNo"; StockColumn.DataPropertyName = "StockNo"; StockColumn.DisplayIndex = 13; StockColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Date.Columns.Add(StockColumn); this.dgv_Date.Columns[this.dgv_Date.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } private void nud_Month_ValueChanged(object sender, EventArgs e) { //DataRow[] searchResultRows = // this.medicineTable.Select(" v<" + this.nud_Month.Value + ""); //DataTable searchResultTable = this.medicineTable.Clone(); //foreach (DataRow row in searchResultRows) //{ // searchResultTable.ImportRow(row); //} //this.dgv_Date.DataSource = searchResultTable; } private void btn_LoadNum_Click(object sender, EventArgs e) { } private void nud_Num_ValueChanged(object sender, EventArgs e) { if (flag == true ) { DataRow[] searchResultRows = this.medicineTable.Select("MNum <" + this.nud_Num.Value + ""); DataTable searchResultTable = this.medicineTable.Clone(); foreach (DataRow row in searchResultRows) { searchResultTable.ImportRow(row); } this.dgv_Date.DataSource = searchResultTable; } else { MessageBox.Show("请先点击左边“库存预警"); } } private void timer1_Tick(object sender, EventArgs e) { Graphics g = this.lb_message .CreateGraphics(); SizeF s = new SizeF(); s = g.MeasureString(text, f);//测量文字长度 Brush brush = Brushes.Black; g.Clear(c);//清除背景 if (temp != text)//文字改变时,重新显示 { p = new PointF(this.lb_message .Size.Width, 0); temp = text; } else p = new PointF(p.X - 50, 0);//每次偏移10 if (p.X <= -s.Width) p = new PointF(this.lb_message .Size.Width, 0); g.DrawString(text, f, brush, p); } private void button2_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { this.flag = true ; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); SqlCommand sqlcommand1 = new SqlCommand(); SqlCommand sqlCommand2 = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlcommand1.Connection = sqlConnection; sqlCommand2.Connection = sqlConnection; sqlCommand.CommandText = "SELECT * FROM tb_Supply;"; sqlcommand1.CommandText = "SELECT * FROM Tb_Stock"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; this.SupplyTable = new DataTable(); SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); sqlDataAdapter1.SelectCommand = sqlcommand1; this.StockTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(this.SupplyTable); sqlDataAdapter1.Fill(this.StockTable); sqlCommand2.CommandText = "SELECT MNo,MName,MNum,Norm,MPrice,ValidDate,isOTC,StockNo FROM tb_medicine where MNum<"+this.nud_Num .Value +" order by MNum Desc;"; SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); sqlDataAdapter2.SelectCommand = sqlCommand2; this.medicineTable = new DataTable(); sqlDataAdapter2.Fill(this.medicineTable); sqlConnection.Close(); this.dgv_Date.Columns.Clear(); this.dgv_Date.DataSource = this.medicineTable; this.dgv_Date.Columns["MNo"].Visible = false; this.dgv_Date.Columns["MName"].HeaderText = "药品名称"; this.dgv_Date.Columns["MNum"].HeaderText = "库存"; this.dgv_Date.Columns["Norm"].HeaderText = "规格"; this.dgv_Date.Columns["MPrice"].HeaderText = "单价"; this.dgv_Date.Columns["ValidDate"].HeaderText = "有效期至"; this.dgv_Date.Columns["IsOTC"].HeaderText = "是否为非处方药"; this.dgv_Date.Columns["StockNo"].Visible = false; //将数据网格视图的指定列设为不可见; //this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = // DataGridViewAutoSizeColumnMode.Fill; //DataGridViewComboBoxColumn SupplyColumn = new DataGridViewComboBoxColumn(); //SupplyColumn.Name = "SupplyName"; //SupplyColumn.HeaderText = "供应商"; //SupplyColumn.DataSource = this.SupplyTable; //SupplyColumn.DisplayMember = "SupplyName"; //SupplyColumn.ValueMember = "SupplyNo"; //SupplyColumn.DataPropertyName = "SupplyNo"; //SupplyColumn.DisplayIndex = 12; //SupplyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; //this.dgv_Date.Columns.Add(SupplyColumn); DataGridViewComboBoxColumn StockColumn = new DataGridViewComboBoxColumn(); StockColumn.Name = "StockName"; StockColumn.HeaderText = "药库"; StockColumn.DataSource = this.StockTable; StockColumn.DisplayMember = "StockName"; StockColumn.ValueMember = "StockNo"; StockColumn.DataPropertyName = "StockNo"; StockColumn.DisplayIndex = 13; StockColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Date.Columns.Add(StockColumn); this.dgv_Date.Columns[this.dgv_Date.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } private void trv_Menu_AfterSelect(object sender, TreeViewEventArgs e) { if (this.trv_Menu.SelectedNode == xinxinode_Client) { this.Hide(); frm_Client f = new frm_Client(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Supply) { this.Hide(); frm_Supply f = new frm_Supply(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Medicine) { this.Hide(); medicine f = new medicine(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_caigou) { this.Hide(); frm_caigou f = new frm_caigou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_jiesuan) { this.Hide(); frm_caigouOrder f = new frm_caigouOrder(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_ruku) { this.Hide(); frm_caigouStored f = new frm_caigouStored(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == chuhuoNode_yuji) { this.Hide(); frm_chushou f = new frm_chushou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == qijianNode_caigou) { this.Hide(); frm_Analysis_qijian f = new frm_Analysis_qijian(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jiduNode_caigou) { this.Hide(); frm_Analysis f = new frm_Analysis(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_youxiaoqi) { this.Hide(); frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kukunNode_kucun) { this.Hide(); frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_yaoku) { this.Hide(); frm_Stock f = new frm_Stock(); f.ShowDialog(this); } } private void person_Click(object sender, EventArgs e) { this.Hide(); personnel p = new personnel(); p.ShowDialog(this); } private void 退出登录ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("确认退出本系统?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Application.Exit(); } } private void lianxiToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("致电谢雪妮:15060120822"); } private void 修改密码_Click(object sender, EventArgs e) { this.Hide(); frm_FindPwd f = new frm_FindPwd(); f.ShowDialog(this); } } }
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; using System.Data.SqlClient; using System.Configuration; namespace 药品信息管理系统 { public partial class frm_ReturnHistory : Form { private DataTable StoredTable; public frm_ReturnHistory() { this.StartPosition = FormStartPosition.CenterScreen; InitializeComponent(); dgv_Medicine.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv_Medicine.ColumnHeadersHeight = 30; dgv_Medicine.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dgv_Medicine.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 10, FontStyle.Bold); dgv_Medicine.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Medicine.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Medicine.ColumnHeadersDefaultCellStyle.ForeColor = ColorTranslator.FromHtml("#fff"); dgv_Medicine.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Medicine.GridColor = ColorTranslator.FromHtml("#006CB3"); dgv_Medicine.BackgroundColor = ColorTranslator.FromHtml("#E7F5FF"); dgv_Medicine.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Medicine.RowHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Medicine.RowTemplate.Height = 30; dgv_Medicine.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Medicine.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#97D5FF"); dgv_Medicine.AlternatingRowsDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#E1F3FF"); } private void frm_ReturnHistory_Load(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "select s.caigouNo,s.caigouDate,s.PaidDate,ss.SupplyName,t.AName,s.PaidAdmin,m.MNo,m.MName,s.num,s.isPaid,isReturn from tb_SelectMedicineBySupply as s join tb_medicine as m on m.MNo =s.MNo join tb_Supply as ss on ss.SupplyNo=s.SupplyNo join tb_Admin as t on t.ANo=s.ANo where s.isPaid=1 and isReturn=1"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; //DataTable ClientTable = new DataTable(); this.StoredTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(this.StoredTable); sqlConnection.Close(); this.dgv_Medicine.Columns.Clear(); this.dgv_Medicine.DataSource = this.StoredTable; this.dgv_Medicine.Columns["caigouDate"].HeaderText = "采购日期"; this.dgv_Medicine.Columns["caigouDate"].ReadOnly = true; this.dgv_Medicine.Columns["SupplyName"].HeaderText = "供应商"; this.dgv_Medicine.Columns["caigouNo"].HeaderText = "流水号"; this.dgv_Medicine.Columns["MName"].HeaderText = "药品名称"; this.dgv_Medicine.Columns["num"].HeaderText = "药品数量"; this.dgv_Medicine.Columns["PaidAdmin"].HeaderText = "结算员"; this.dgv_Medicine.Columns["MNo"].HeaderText = "药品编号"; //this.dgv_Client.Columns["pinyin"].Visible = false; this.dgv_Medicine.Columns["PaidDate"].HeaderText = "结算日期"; this.dgv_Medicine.Columns["isPaid"].HeaderText = "付款状态"; this.dgv_Medicine.Columns["AName"].HeaderText = "采购员"; this.dgv_Medicine.Columns["isReturn"].HeaderText = "是否退货"; //dgv_Medicine.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //this.dgv_Medicine.Columns["CName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } } }
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; using System.Data.SqlClient; using System.Configuration; using System.Drawing.Printing; namespace 药品信息管理系统 { public partial class frm_seek : Form { TreeNode xinxinode = new TreeNode(); TreeNode jinhuonode = new TreeNode(); TreeNode chuhuonode = new TreeNode(); TreeNode kucunnode = new TreeNode(); TreeNode tongjinode = new TreeNode(); TreeNode xitongnode = new TreeNode(); TreeNode xinxinode_Client = new TreeNode(); TreeNode xinxinode_Supply = new TreeNode(); TreeNode xinxinode_Medicine = new TreeNode(); TreeNode jinhuoNode_caigou = new TreeNode(); TreeNode jinhuoNode_jiesuan = new TreeNode(); TreeNode jinhuoNode_ruku = new TreeNode(); TreeNode chuhuoNode_yuji = new TreeNode(); TreeNode qijianNode_caigou = new TreeNode(); TreeNode jiduNode_caigou = new TreeNode(); TreeNode kucunNode_youxiaoqi = new TreeNode(); TreeNode kukunNode_kucun = new TreeNode(); TreeNode kucunNode_yaoku = new TreeNode(); private DataTable medicineTable; private DataTable SupplyTable; private DataTable StockTable; //private Label label = new Label(); public String MName; public String Stock; public String he; public string text; private bool flag=false ; public frm_seek() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; this.dgv_Date.AllowUserToAddRows = false ; this.dgv_Date.RowHeadersVisible = false ; this.dgv_Date.BackgroundColor = Color.White; this.dgv_Date.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Date.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv_Date.ColumnHeadersHeight = 30; dgv_Date.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Date.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 10, FontStyle.Bold); dgv_Date.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Date.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Date.ColumnHeadersDefaultCellStyle.ForeColor = ColorTranslator.FromHtml("#fff"); dgv_Date.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Date.GridColor = ColorTranslator.FromHtml("#006CB3"); dgv_Date.BackgroundColor = ColorTranslator.FromHtml("#E7F5FF"); dgv_Date.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Date.RowHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Date.RowTemplate.Height = 30; dgv_Date.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Date.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#97D5FF"); dgv_Date.AlternatingRowsDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#E1F3FF"); } //private DataTable SupplyTable; //private DataTable StockTable; //private DataTable medicineTable; PointF p; Font f = new Font("宋体", 15); Color c = Color.White; string temp; private void frm_seek_Load(object sender, EventArgs e) { this.trv_Menu.BackColor = Color.AliceBlue; this.trv_Menu.SelectedNode = null; this.trv_Menu.ExpandAll(); //this.trv_Menu.SelectedNode = this.trv_Menu.Nodes[0]; //展开组件中的所有节点 //this.trv_Menu.SelectedNode.ExpandAll(); //this.trv_Menu.SelectedNode.Nodes .Add () //this.trv_Menu.Expanded = true; //this.trv_Menu.Nodes[1].Expand(); trv_Menu.LabelEdit = true;//可编辑状态。 //添加一个节点,这个结点是根节点。 xinxinode.Text = "信息维护"; xinxinode.Expand(); xinxinode.ImageIndex = 5; jinhuonode.Text = "进货管理"; jinhuonode.Expand(); jinhuonode.ImageIndex = 9; chuhuonode.Text = "出货管理"; chuhuonode.Expand(); chuhuonode.ImageIndex = 10; kucunnode.Text = "库存管理"; kucunnode.ImageIndex = 8; kucunnode.Expand(); tongjinode.Text = "采购统计"; tongjinode.ImageIndex = 3; xitongnode.Text = "系统设置"; xitongnode.ImageIndex = 7; //TreeNode node6 = new TreeNode(); //node6.Text = "库存管理"; trv_Menu.Nodes.Add(xinxinode); trv_Menu.Nodes.Add(jinhuonode); trv_Menu.Nodes.Add(chuhuonode); trv_Menu.Nodes.Add(kucunnode); trv_Menu.Nodes.Add(tongjinode); trv_Menu.Nodes.Add(xitongnode); //信息维护根节点下 xinxinode_Client.Text = "会员信息维护"; xinxinode_Client.ImageIndex = 2; xinxinode_Client.NodeFont = new Font("幼圆", 11); xinxinode_Supply.Text = "供应商信息维护"; xinxinode_Supply.ImageIndex = 1; xinxinode_Supply.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.Text = "药品信息维护"; xinxinode_Medicine.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.ImageIndex = 6; xinxinode.Nodes.Add(xinxinode_Client); xinxinode.Nodes.Add(xinxinode_Supply); xinxinode.Nodes.Add(xinxinode_Medicine); //进货管理根节点下 jinhuoNode_caigou.Text = "采集药品"; jinhuoNode_caigou.NodeFont = new Font("幼圆", 11); jinhuoNode_jiesuan.Text = "订单结算审核"; jinhuoNode_jiesuan.NodeFont = new Font("幼圆", 11); jinhuoNode_ruku.Text = "药品审核入库"; jinhuoNode_ruku.NodeFont = new Font("幼圆", 11); jinhuonode.Nodes.Add(jinhuoNode_caigou); jinhuonode.Nodes.Add(jinhuoNode_jiesuan); jinhuonode.Nodes.Add(jinhuoNode_ruku); //出货管理根节点下 chuhuoNode_yuji.Text = "出售药品"; chuhuoNode_yuji.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_shoukuan = new TreeNode(); //chuhuoNode_shoukuan.Text = "收款审核"; //chuhuoNode_shoukuan.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_chuku = new TreeNode(); //chuhuoNode_chuku.Text = "药品审核出库"; //chuhuoNode_chuku.NodeFont = new Font("幼圆", 11); chuhuonode.Nodes.Add(chuhuoNode_yuji); //chuhuonode.Nodes.Add(chuhuoNode_shoukuan); //chuhuonode.Nodes.Add(chuhuoNode_chuku); //统计管理根节点下 qijianNode_caigou.Text = "期间统计分析"; qijianNode_caigou.NodeFont = new Font("幼圆", 11); jiduNode_caigou.Text = "季度统计分析"; jiduNode_caigou.NodeFont = new Font("幼圆", 11); tongjinode.Nodes.Add(jiduNode_caigou); tongjinode.Nodes.Add(qijianNode_caigou); //库存管理根节点下 kucunNode_youxiaoqi.Text = "有效期提示"; kucunNode_youxiaoqi.NodeFont = new Font("幼圆", 11); kucunNode_youxiaoqi.ImageIndex = 4; kucunNode_youxiaoqi.BackColor = Color.Red; kukunNode_kucun.Text = "库存量查询"; kukunNode_kucun.NodeFont = new Font("幼圆", 11); kukunNode_kucun.BackColor = Color.Red; kucunNode_yaoku.Text = "药库管理"; kucunNode_yaoku.NodeFont = new Font("幼圆", 11); kucunnode.Nodes.Add(kucunNode_youxiaoqi); kucunnode.Nodes.Add(kukunNode_kucun); kucunnode.Nodes.Add(kucunNode_yaoku); //this.trv_Menu.CheckBoxes = true; this.trv_Menu.ExpandAll(); //this.label.Location = new Point(10, 436); //this.label.BackColor = Color.Transparent; //this.label.Size = new Size(1000, 30); this.Controls.Add(lb_message ); //this.label.Text = ""; this.timer1.Enabled = true; this.timer1.Interval = 200; p = new PointF(this.lb_message .Size.Width, 0); 管理员ToolStripMenuItem.Text = frm_LogIn.AdminName.ToString(); using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlcommand = new SqlCommand(); sqlcommand.Connection = sqlConnection; sqlcommand.CommandText = "select m.MNo,m.MName,m.MNum,m.Norm,m.MPrice,m.ValidDate,s.StockName from tb_Medicine as m join tb_Stock as s on s.StockNo=m.StockNo where DATEDIFF(Day, getdate(),m.ValidDate) <1"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlcommand; DataTable Table = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(Table); sqlConnection.Close(); this.dgv_Date.Columns.Clear(); this.dgv_Date.DataSource = Table; this.dgv_Date.Columns["MNo"].HeaderText = "药品编号"; this.dgv_Date.Columns["MName"].HeaderText = "药品名称"; this.dgv_Date.Columns["MNum"].HeaderText = "库存"; this.dgv_Date.Columns["Norm"].HeaderText = "规格"; this.dgv_Date.Columns["MPrice"].HeaderText = "单价"; this.dgv_Date.Columns["ValidDate"].HeaderText = "有效期至"; this.dgv_Date.Columns["StockName"].HeaderText = "所在药库"; //this.dgv_Date.Columns["Photo"].Visible = false; for (int i = 0; i < this.dgv_Date.RowCount; i++) { this.MName = this.dgv_Date.Rows[i].Cells[1].Value.ToString(); this.Stock = this.dgv_Date.Rows[i].Cells[6].Value.ToString(); this.he = this.Stock + "的" + this.MName + "过期了噢!"; this.text += he + " "; this.dgv_Date.Rows[i].Cells[5].Style.ForeColor = Color.Red; } this.dgv_Date.Columns[this.dgv_Date.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } private void btn_Load_Click(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlcommand1 = new SqlCommand(); SqlCommand sqlCommand2 = new SqlCommand(); sqlcommand1.Connection = sqlConnection; sqlCommand2.Connection = sqlConnection; sqlcommand1.CommandText = "SELECT * FROM Tb_Stock"; sqlCommand2.CommandText = " select * from tb_medicine as m where DATEDIFF(month, getdate(),m.ValidDate) <" + this.nud_Month.Value + ""; SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); sqlDataAdapter1.SelectCommand = sqlcommand1; DataTable StockTable = new DataTable(); SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); sqlDataAdapter2.SelectCommand = sqlCommand2; DataTable medicineTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter1.Fill(StockTable); sqlDataAdapter2.Fill(medicineTable); sqlConnection.Close(); this.dgv_Date.Columns.Clear(); this.dgv_Date.DataSource = medicineTable; this.dgv_Date.Columns["MNo"].Visible = false; this.dgv_Date.Columns["MName"].HeaderText = "药品名称"; this.dgv_Date.Columns["MNum"].HeaderText = "库存"; this.dgv_Date.Columns["Norm"].HeaderText = "规格"; this.dgv_Date.Columns["MPrice"].HeaderText = "单价"; this.dgv_Date.Columns["ValidDate"].HeaderText = "有效期至"; //this.dgv_Date.Columns["v"].HeaderText = "距离过期还剩 _月"; this.dgv_Date.Columns["IsOTC"].HeaderText = "是否为非处方药"; this.dgv_Date.Columns["Instuction"].Visible = false; this.dgv_Date.Columns["SupplyNo"].Visible = false; this.dgv_Date.Columns["StockNo"].Visible = false; this.dgv_Date.Columns["Photo"].Visible = false; //this.dgv_Date.Columns["pinyin"].Visible = false; DataGridViewComboBoxColumn StockColumn = new DataGridViewComboBoxColumn(); StockColumn.Name = "StockName"; StockColumn.HeaderText = "所在药库"; StockColumn.DataSource = StockTable; StockColumn.DisplayMember = "StockName"; StockColumn.ValueMember = "StockNo"; StockColumn.DataPropertyName = "StockNo"; StockColumn.DisplayIndex = 13; StockColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Date.Columns.Add(StockColumn); this.dgv_Date.Columns[this.dgv_Date.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } private void nud_Month_ValueChanged(object sender, EventArgs e) { //DataRow[] searchResultRows = // this.medicineTable.Select(" v<" + this.nud_Month.Value + ""); //DataTable searchResultTable = this.medicineTable.Clone(); //foreach (DataRow row in searchResultRows) //{ // searchResultTable.ImportRow(row); //} //this.dgv_Date.DataSource = searchResultTable; } private void btn_LoadNum_Click(object sender, EventArgs e) { } private void nud_Num_ValueChanged(object sender, EventArgs e) { if (flag == true ) { DataRow[] searchResultRows = this.medicineTable.Select("MNum <" + this.nud_Num.Value + ""); DataTable searchResultTable = this.medicineTable.Clone(); foreach (DataRow row in searchResultRows) { searchResultTable.ImportRow(row); } this.dgv_Date.DataSource = searchResultTable; } else { MessageBox.Show("请先点击左边“库存预警"); } } private void timer1_Tick(object sender, EventArgs e) { Graphics g = this.lb_message .CreateGraphics(); SizeF s = new SizeF(); s = g.MeasureString(text, f);//测量文字长度 Brush brush = Brushes.Black; g.Clear(c);//清除背景 if (temp != text)//文字改变时,重新显示 { p = new PointF(this.lb_message .Size.Width, 0); temp = text; } else p = new PointF(p.X - 50, 0);//每次偏移10 if (p.X <= -s.Width) p = new PointF(this.lb_message .Size.Width, 0); g.DrawString(text, f, brush, p); } private void button2_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { this.flag = true ; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); SqlCommand sqlcommand1 = new SqlCommand(); SqlCommand sqlCommand2 = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlcommand1.Connection = sqlConnection; sqlCommand2.Connection = sqlConnection; sqlCommand.CommandText = "SELECT * FROM tb_Supply;"; sqlcommand1.CommandText = "SELECT * FROM Tb_Stock"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; this.SupplyTable = new DataTable(); SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); sqlDataAdapter1.SelectCommand = sqlcommand1; this.StockTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(this.SupplyTable); sqlDataAdapter1.Fill(this.StockTable); sqlCommand2.CommandText = "SELECT MNo,MName,MNum,Norm,MPrice,ValidDate,isOTC,StockNo FROM tb_medicine where MNum<"+this.nud_Num .Value +" order by MNum Desc;"; SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); sqlDataAdapter2.SelectCommand = sqlCommand2; this.medicineTable = new DataTable(); sqlDataAdapter2.Fill(this.medicineTable); sqlConnection.Close(); this.dgv_Date.Columns.Clear(); this.dgv_Date.DataSource = this.medicineTable; this.dgv_Date.Columns["MNo"].Visible = false; this.dgv_Date.Columns["MName"].HeaderText = "药品名称"; this.dgv_Date.Columns["MNum"].HeaderText = "库存"; this.dgv_Date.Columns["Norm"].HeaderText = "规格"; this.dgv_Date.Columns["MPrice"].HeaderText = "单价"; this.dgv_Date.Columns["ValidDate"].HeaderText = "有效期至"; this.dgv_Date.Columns["IsOTC"].HeaderText = "是否为非处方药"; this.dgv_Date.Columns["StockNo"].Visible = false; //将数据网格视图的指定列设为不可见; //this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = // DataGridViewAutoSizeColumnMode.Fill; //DataGridViewComboBoxColumn SupplyColumn = new DataGridViewComboBoxColumn(); //SupplyColumn.Name = "SupplyName"; //SupplyColumn.HeaderText = "供应商"; //SupplyColumn.DataSource = this.SupplyTable; //SupplyColumn.DisplayMember = "SupplyName"; //SupplyColumn.ValueMember = "SupplyNo"; //SupplyColumn.DataPropertyName = "SupplyNo"; //SupplyColumn.DisplayIndex = 12; //SupplyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; //this.dgv_Date.Columns.Add(SupplyColumn); DataGridViewComboBoxColumn StockColumn = new DataGridViewComboBoxColumn(); StockColumn.Name = "StockName"; StockColumn.HeaderText = "药库"; StockColumn.DataSource = this.StockTable; StockColumn.DisplayMember = "StockName"; StockColumn.ValueMember = "StockNo"; StockColumn.DataPropertyName = "StockNo"; StockColumn.DisplayIndex = 13; StockColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Date.Columns.Add(StockColumn); this.dgv_Date.Columns[this.dgv_Date.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } private void trv_Menu_AfterSelect(object sender, TreeViewEventArgs e) { if (this.trv_Menu.SelectedNode == xinxinode_Client) { this.Hide(); frm_Client f = new frm_Client(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Supply) { this.Hide(); frm_Supply f = new frm_Supply(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Medicine) { this.Hide(); medicine f = new medicine(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_caigou) { this.Hide(); frm_caigou f = new frm_caigou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_jiesuan) { this.Hide(); frm_caigouOrder f = new frm_caigouOrder(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_ruku) { this.Hide(); frm_caigouStored f = new frm_caigouStored(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == chuhuoNode_yuji) { this.Hide(); frm_chushou f = new frm_chushou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == qijianNode_caigou) { this.Hide(); frm_Analysis_qijian f = new frm_Analysis_qijian(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jiduNode_caigou) { this.Hide(); frm_Analysis f = new frm_Analysis(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_youxiaoqi) { this.Hide(); frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kukunNode_kucun) { this.Hide(); frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_yaoku) { this.Hide(); frm_Stock f = new frm_Stock(); f.ShowDialog(this); } } private void person_Click(object sender, EventArgs e) { this.Hide(); personnel p = new personnel(); p.ShowDialog(this); } private void 退出登录ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("确认退出本系统?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Application.Exit(); } } private void lianxiToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("致电谢雪妮:15060120822"); } private void 修改密码_Click(object sender, EventArgs e) { this.Hide(); frm_FindPwd f = new frm_FindPwd(); f.ShowDialog(this); } } }
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; using System.Data.SqlClient; using System.Configuration; namespace 药品信息管理系统 { public partial class frm_Stock : Form { DataTable medicineTable; TreeNode xinxinode = new TreeNode(); TreeNode jinhuonode = new TreeNode(); TreeNode chuhuonode = new TreeNode(); TreeNode kucunnode = new TreeNode(); TreeNode tongjinode = new TreeNode(); TreeNode xitongnode = new TreeNode(); TreeNode xinxinode_Client = new TreeNode(); TreeNode xinxinode_Supply = new TreeNode(); TreeNode xinxinode_Medicine = new TreeNode(); TreeNode jinhuoNode_caigou = new TreeNode(); TreeNode jinhuoNode_jiesuan = new TreeNode(); TreeNode jinhuoNode_ruku = new TreeNode(); TreeNode chuhuoNode_yuji = new TreeNode(); TreeNode qijianNode_caigou = new TreeNode(); TreeNode jiduNode_caigou = new TreeNode(); TreeNode kucunNode_youxiaoqi = new TreeNode(); TreeNode kukunNode_kucun = new TreeNode(); TreeNode kucunNode_yaoku = new TreeNode(); private string StockNo; public string StockName; public frm_Stock() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; this.dgv_Medicine.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Medicine.AlternatingRowsDefaultCellStyle.BackColor = Color.LightBlue ; this.dgv_Medicine.BackgroundColor = Color.White; dgv_Medicine.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv_Medicine.ColumnHeadersHeight = 30; dgv_Medicine.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Medicine.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 10, FontStyle.Bold); dgv_Medicine.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Medicine.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Medicine.ColumnHeadersDefaultCellStyle.ForeColor = ColorTranslator.FromHtml("#fff"); dgv_Medicine.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Medicine.GridColor = ColorTranslator.FromHtml("#006CB3"); dgv_Medicine.BackgroundColor = ColorTranslator.FromHtml("#E7F5FF"); dgv_Medicine.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Medicine.RowHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Medicine.RowTemplate.Height = 30; dgv_Medicine.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Medicine.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#97D5FF"); dgv_Medicine.AlternatingRowsDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#E1F3FF"); } private void frm_Stock_Load(object sender, EventArgs e) { if(this.dgv_Medicine .DataSource ==null ) { btn_Update.Enabled = false; } else { btn_Update.Enabled = true; } this.trv_Menu.BackColor = Color.AliceBlue; this.trv_Menu.SelectedNode = null; this.trv_Menu.ExpandAll(); //this.trv_Menu.SelectedNode = this.trv_Menu.Nodes[0]; //展开组件中的所有节点 //this.trv_Menu.SelectedNode.ExpandAll(); //this.trv_Menu.SelectedNode.Nodes .Add () //this.trv_Menu.Expanded = true; //this.trv_Menu.Nodes[1].Expand(); trv_Menu.LabelEdit = true;//可编辑状态。 //添加一个节点,这个结点是根节点。 xinxinode.Text = "信息维护"; xinxinode.Expand(); xinxinode.ImageIndex = 5; jinhuonode.Text = "进货管理"; jinhuonode.Expand(); jinhuonode.ImageIndex = 9; chuhuonode.Text = "出货管理"; chuhuonode.Expand(); chuhuonode.ImageIndex = 10; kucunnode.Text = "库存管理"; kucunnode.ImageIndex = 8; kucunnode.Expand(); tongjinode.Text = "采购统计"; tongjinode.ImageIndex = 3; xitongnode.Text = "系统设置"; xitongnode.ImageIndex = 7; //TreeNode node6 = new TreeNode(); //node6.Text = "库存管理"; trv_Menu.Nodes.Add(xinxinode); trv_Menu.Nodes.Add(jinhuonode); trv_Menu.Nodes.Add(chuhuonode); trv_Menu.Nodes.Add(kucunnode); trv_Menu.Nodes.Add(tongjinode); trv_Menu.Nodes.Add(xitongnode); //信息维护根节点下 xinxinode_Client.Text = "会员信息维护"; xinxinode_Client.ImageIndex = 2; xinxinode_Client.NodeFont = new Font("幼圆", 11); xinxinode_Supply.Text = "供应商信息维护"; xinxinode_Supply.ImageIndex = 1; xinxinode_Supply.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.Text = "药品信息维护"; xinxinode_Medicine.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.ImageIndex = 6; xinxinode.Nodes.Add(xinxinode_Client); xinxinode.Nodes.Add(xinxinode_Supply); xinxinode.Nodes.Add(xinxinode_Medicine); //进货管理根节点下 jinhuoNode_caigou.Text = "采集药品"; jinhuoNode_caigou.NodeFont = new Font("幼圆", 11); jinhuoNode_jiesuan.Text = "订单结算审核"; jinhuoNode_jiesuan.NodeFont = new Font("幼圆", 11); jinhuoNode_ruku.Text = "药品审核入库"; jinhuoNode_ruku.NodeFont = new Font("幼圆", 11); jinhuonode.Nodes.Add(jinhuoNode_caigou); jinhuonode.Nodes.Add(jinhuoNode_jiesuan); jinhuonode.Nodes.Add(jinhuoNode_ruku); //出货管理根节点下 chuhuoNode_yuji.Text = "出售药品"; chuhuoNode_yuji.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_shoukuan = new TreeNode(); //chuhuoNode_shoukuan.Text = "收款审核"; //chuhuoNode_shoukuan.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_chuku = new TreeNode(); //chuhuoNode_chuku.Text = "药品审核出库"; //chuhuoNode_chuku.NodeFont = new Font("幼圆", 11); chuhuonode.Nodes.Add(chuhuoNode_yuji); //chuhuonode.Nodes.Add(chuhuoNode_shoukuan); //chuhuonode.Nodes.Add(chuhuoNode_chuku); //统计管理根节点下 qijianNode_caigou.Text = "期间统计分析"; qijianNode_caigou.NodeFont = new Font("幼圆", 11); jiduNode_caigou.Text = "季度统计分析"; jiduNode_caigou.NodeFont = new Font("幼圆", 11); tongjinode.Nodes.Add(jiduNode_caigou); tongjinode.Nodes.Add(qijianNode_caigou); //库存管理根节点下 kucunNode_youxiaoqi.Text = "有效期提示"; kucunNode_youxiaoqi.NodeFont = new Font("幼圆", 11); kucunNode_youxiaoqi.ImageIndex = 4; kukunNode_kucun.Text = "库存量查询"; kukunNode_kucun.NodeFont = new Font("幼圆", 11); kucunNode_yaoku.Text = "药库管理"; kucunNode_yaoku.NodeFont = new Font("幼圆", 11); kucunNode_yaoku.BackColor = Color.Red; kucunnode.Nodes.Add(kucunNode_youxiaoqi); kucunnode.Nodes.Add(kukunNode_kucun); kucunnode.Nodes.Add(kucunNode_yaoku); //this.trv_Menu.CheckBoxes = true; this.trv_Menu.ExpandAll(); 管理员ToolStripMenuItem.Text = frm_LogIn.AdminName.ToString(); using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "SELECT * FROM tb_StockClassify;" + "SELECT * FROM tb_Stock;"; //+ "SELECT * FROM tb_Class;"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; DataSet dataSet = new DataSet(); sqlConnection.Open(); sqlDataAdapter.Fill(dataSet); sqlConnection.Close(); DataTable StockClassifyTable = dataSet.Tables[0]; DataTable StockTable = dataSet.Tables[1]; //DataTable classTable = dataSet.Tables[2]; DataRelation[] dataRelations = { new DataRelation ("StockClassify_Stock" , StockClassifyTable.Columns["No"] , StockTable.Columns["StockClassifyNo"] , false) //, new DataRelation // ("Major_Class" // , majorTable.Columns["No"] // , classTable.Columns["MajorNo"] // , false) }; dataSet.Relations.AddRange(dataRelations); this.trv_StockUnit.Nodes.Clear(); foreach (DataRow StockClassifyRow in StockClassifyTable.Rows) { TreeNode StockClassifyNode = new TreeNode(); StockClassifyNode.Text = StockClassifyRow["Name"].ToString(); this.trv_StockUnit.Nodes.Add(StockClassifyNode); foreach (DataRow StockRow in StockClassifyRow.GetChildRows("StockClassify_Stock")) { TreeNode StockNode = new TreeNode(); StockNode.Text = StockRow["StockName"].ToString(); StockClassifyNode.Nodes.Add(StockNode); StockNode.Tag = StockRow["StockNo"]; } } } } private void btn_Seek_Click(object sender, EventArgs e) { //using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) //{ // SqlCommand sqlCommand2 = new SqlCommand(); // sqlCommand2.Connection = sqlConnection; // sqlCommand2.CommandText = "SELECT * FROM tb_Supply;"; // SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); // sqlDataAdapter2.SelectCommand = sqlCommand2; // DataTable SupplyTable = new DataTable(); // SqlCommand sqlCommand1 = new SqlCommand(); // sqlCommand1.Connection = sqlConnection; // sqlCommand1.CommandText = "SELECT * FROM tb_medicine where StockNo='"+this .cob_StockName.SelectedValue .ToString () +"'"; // SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); // sqlDataAdapter1.SelectCommand = sqlCommand1; // DataTable medicineTable = new DataTable(); // sqlConnection.Open(); // sqlDataAdapter2.Fill(SupplyTable); // sqlDataAdapter1.Fill(medicineTable); // sqlConnection.Close(); // this.dgv_Stock.Columns.Clear(); // this.dgv_Stock.DataSource = medicineTable; // this.dgv_Stock.Columns["MNo"].HeaderText = "药品编号"; // this.dgv_Stock.Columns["MName"].HeaderText = "药品名称"; // this.dgv_Stock.Columns["MNum"].HeaderText = "库存"; // this.dgv_Stock.Columns["Norm"].HeaderText = "规格"; // this.dgv_Stock.Columns["MPrice"].HeaderText = "单价"; // this.dgv_Stock.Columns["ValidDate"].HeaderText = "有效期至"; // this.dgv_Stock.Columns["IsOTC"].HeaderText = "是否为非处方药"; // this.dgv_Stock.Columns["Instuction"].Visible = false; // this.dgv_Stock.Columns["SupplyNo"].Visible = false ; // this.dgv_Stock.Columns["StockNo"].Visible = false; // this.dgv_Stock.Columns["Photo"].Visible = false; // this.dgv_Stock .Columns ["pinyin"].Visible =false ; // DataGridViewComboBoxColumn SupplyColumn = new DataGridViewComboBoxColumn(); // SupplyColumn.Name = "SupplyName"; // SupplyColumn.HeaderText = "供应商"; // SupplyColumn.DataSource = SupplyTable; // SupplyColumn.DisplayMember = "SupplyName"; // SupplyColumn.ValueMember = "SupplyNo"; // SupplyColumn.DataPropertyName = "SupplyNo"; // SupplyColumn.DisplayIndex = 12; // SupplyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; // this.dgv_Stock.Columns.Add(SupplyColumn); // this.dgv_Stock.Columns[this.dgv_Stock.Columns.Count - 1].AutoSizeMode = // DataGridViewAutoSizeColumnMode.Fill; // sqlConnection.Open(); // SqlCommand StockCommand = new SqlCommand(); // StockCommand.Connection = sqlConnection; // StockCommand.CommandText = "select s.*,a.ANO,a.AName from tb_Stock as s join tb_Admin as a on a.ANO=s.ANO where StockNO='" + this.cob_StockName.SelectedValue.ToString() + "'"; // SqlDataAdapter StockAdapter = new SqlDataAdapter(); // StockAdapter.SelectCommand = StockCommand; // DataTable StockTable = new DataTable(); // StockAdapter.Fill(StockTable); // SqlDataReader StockReader = StockCommand.ExecuteReader(); // while (StockReader.Read()) // { // lb_StockInstruction.Text = " "+StockReader["StockInstruction"].ToString(); // lb_StockName.Text = "本药库为" + cob_StockName.Text+"。"+"现存"+medicineTable.Compute("Count(MNo)", "").ToString()+"种药品"; // lb_StockAdmin.Text = "本药库管员:" + StockReader["AName"].ToString(); // } // StockReader.Close(); // sqlConnection.Close(); //} } private void btn_Submit_Click(object sender, EventArgs e) { } private void dgv_Stock_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void btn_Load_Click(object sender, EventArgs e) { } private void trv_StockUnit_AfterSelect(object sender, TreeViewEventArgs e) { if (this.trv_StockUnit.SelectedNode.Level == 1) { this.StockNo = (String )this.trv_StockUnit.SelectedNode.Tag; this.StockName = this.trv_StockUnit.SelectedNode.Text.Trim (); using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand2 = new SqlCommand(); sqlCommand2.Connection = sqlConnection; sqlCommand2.CommandText = "SELECT * FROM tb_Supply;"; SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); sqlDataAdapter2.SelectCommand = sqlCommand2; DataTable SupplyTable = new DataTable(); SqlCommand sqlCommand1 = new SqlCommand(); sqlCommand1.Connection = sqlConnection; sqlCommand1.CommandText = "SELECT MNo,MName,MNum,Norm,ValidDate,SupplyNo, MPrice,IsOTC FROM tb_medicine where StockNo=@StockNo"; sqlCommand1.Parameters.AddWithValue("@StockNo", StockNo); SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); sqlDataAdapter1.SelectCommand = sqlCommand1; this.medicineTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter2.Fill(SupplyTable); sqlDataAdapter1.Fill(this.medicineTable); sqlConnection.Close(); this.dgv_Medicine.Columns.Clear(); this.dgv_Medicine.DataSource = this.medicineTable; this.dgv_Medicine.Columns["MNo"].HeaderText = "药品编号"; this.dgv_Medicine.Columns["MName"].HeaderText = "药品名称"; this.dgv_Medicine.Columns["MNum"].HeaderText = "库存"; this.dgv_Medicine.Columns["Norm"].HeaderText = "规格"; this.dgv_Medicine.Columns["MPrice"].Visible = false; this.dgv_Medicine.Columns["ValidDate"].HeaderText = "有效期至"; this.dgv_Medicine.Columns["IsOTC"].Visible = false; this.dgv_Medicine.Columns["SupplyNo"].Visible = false; DataGridViewComboBoxColumn SupplyColumn = new DataGridViewComboBoxColumn(); SupplyColumn.Name = "SupplyName"; SupplyColumn.HeaderText = "供应商"; SupplyColumn.DataSource = SupplyTable; SupplyColumn.DisplayMember = "SupplyName"; SupplyColumn.ValueMember = "SupplyNo"; SupplyColumn.DataPropertyName = "SupplyNo"; SupplyColumn.DisplayIndex = 12; SupplyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Medicine.Columns.Add(SupplyColumn); this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; sqlConnection.Open(); SqlCommand StockCommand = new SqlCommand(); StockCommand.Connection = sqlConnection; StockCommand.CommandText = "select s.*,a.ANO,a.AName from tb_Stock as s join tb_Admin as a on a.ANO=s.ANO where StockNO='" + this.StockNo .ToString ()+ "'"; SqlDataAdapter StockAdapter = new SqlDataAdapter(); StockAdapter.SelectCommand = StockCommand; DataTable StockTable = new DataTable(); StockAdapter.Fill(StockTable); SqlDataReader StockReader = StockCommand.ExecuteReader(); while (StockReader.Read()) { lb_StockInstruction.Text = " " + StockReader["StockInstruction"].ToString(); lb_StockName.Text = " "+"本药库为" + this.StockName+ "。" + "现存" + this.medicineTable.Compute("Count(MNo)", "").ToString() + "种药品"; lb_StockAdmin.Text = " "+"本药库管员:" + StockReader["AName"].ToString(); } StockReader.Close(); sqlConnection.Close(); for (int i = 0; i < this.dgv_Medicine .RowCount; i++) { DateTime dt=new DateTime (); dt =Convert.ToDateTime ( this.dgv_Medicine.Rows [i].Cells [4].Value); TimeSpan span = DateTime.Now - dt; if (span.TotalDays >0) { this.dgv_Medicine.Rows[i].Cells[4].Style.ForeColor = Color.Red; this.dgv_Medicine.Rows[i].Cells[4].Style.Font = new Font("宋体", 10F, FontStyle.Bold ); } if (Convert .ToInt32 (this.dgv_Medicine.Rows[i].Cells[2].Value) ==0) { this.dgv_Medicine.Rows[i].Cells[2].Style.ForeColor = Color.Red ; this.dgv_Medicine.Rows[i].Cells[2].Style.Font = new Font("宋体", 10F, FontStyle.Italic ); } } } } } private void lb_StockInstruction_Click(object sender, EventArgs e) { } private void btn_GoClean_Click(object sender, EventArgs e) { } private void trv_Menu_AfterSelect(object sender, TreeViewEventArgs e) { //label2.Text = this.trv_Menu.SelectedNode.Index.ToString(); } private void trv_Menu_AfterSelect_1(object sender, TreeViewEventArgs e) { if (this.trv_Menu.SelectedNode == xinxinode_Client) { this.Hide(); frm_Client f = new frm_Client(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Supply) { this.Hide(); frm_Supply f = new frm_Supply(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Medicine) { this.Hide(); medicine f = new medicine(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_caigou) { this.Hide(); frm_caigou f = new frm_caigou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_jiesuan) { this.Hide(); frm_caigouOrder f = new frm_caigouOrder(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_ruku) { this.Hide(); frm_caigouStored f = new frm_caigouStored(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == chuhuoNode_yuji) { this.Hide(); frm_chushou f = new frm_chushou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == qijianNode_caigou) { this.Hide(); frm_Analysis_qijian f = new frm_Analysis_qijian(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jiduNode_caigou) { this.Hide(); frm_Analysis f = new frm_Analysis(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_youxiaoqi) { this.Hide(); frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kukunNode_kucun) { this.Hide(); frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_yaoku) { this.Hide(); frm_Stock f = new frm_Stock(); f.ShowDialog(this); } } private void person_Click(object sender, EventArgs e) { this.Hide(); personnel p = new personnel(); p.ShowDialog(this); } private void 退出登录ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("确认退出本系统?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Application.Exit(); } } private void lianxiToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("致电谢雪妮:15060120822"); } private void 修改密码_Click(object sender, EventArgs e) { this.Hide(); frm_FindPwd f = new frm_FindPwd(); f.ShowDialog(this); } private void btn_delete_Click(object sender, EventArgs e) { MessageBox.Show("对不起!我还是个没用的孩子"); // for (int i = 0; i<=this.medicineTable .Rows .Count;i++) // { // if (this.dgv_Medicine.Rows[i].Cells[4].Style.ForeColor == Color.Red) // { // this.medicineTable.Rows[i].Delete(); // } //} } private void btn_Update_Click(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand insertCommand = new SqlCommand(); insertCommand.Connection = sqlConnection; insertCommand.CommandText = "insert tb_medicine " + " (MNo,MName,IsOTC,MNum,Norm,MPrice,ValidDate,SupplyNo,StockNo) " + " values (@MNo,@MName,@IsOTC,@MNum,@Norm,@MPrice,@ValidDate,@SupplyNo,@StockNo);"; insertCommand.Parameters.Add("@MNo", SqlDbType.Char, 10, "MNo"); insertCommand.Parameters.Add("@MName", SqlDbType.VarChar, 0, "MName"); insertCommand.Parameters.Add("@IsOTC", SqlDbType.Bit, 0, "IsOTC"); insertCommand.Parameters.Add("@MNum", SqlDbType.VarChar, 0, "MNum"); insertCommand.Parameters.Add("@Norm", SqlDbType.VarChar, 10, "Norm"); insertCommand.Parameters.Add("@MPrice", SqlDbType.Money, 0, "MPrice"); insertCommand.Parameters.Add("@ValidDate", SqlDbType.Date, 0, "ValidDate"); insertCommand.Parameters.Add("@SupplyNo", SqlDbType.Char, 10, "SupplyNo"); insertCommand.Parameters.AddWithValue("@StockNo", this.StockNo); SqlCommand updateCommand = new SqlCommand(); updateCommand.Connection = sqlConnection; updateCommand.CommandText = "UPDATE tb_medicine" + " SET MNo=@NewMNo,MName=@MName,IsOTC=@IsOTC,MNum=@MNum,Norm=@Norm,MPrice=@MPrice,ValidDate=@ValidDate,SupplyNo=@SupplyNo,StockNo=@StockNo" + " WHERE MNo=@OldMNo;"; updateCommand.Parameters.Add("@NewMNo", SqlDbType.Char, 10, "MNo"); updateCommand.Parameters.Add("@MName", SqlDbType.VarChar, 0, "MName"); updateCommand.Parameters.Add("@IsOTC", SqlDbType.Bit, 0, "IsOTC"); updateCommand.Parameters.Add("@MNum", SqlDbType.VarChar, 0, "MNum"); updateCommand.Parameters.Add("@Norm", SqlDbType.VarChar, 0, "Norm"); updateCommand.Parameters.Add("@MPrice", SqlDbType.Money, 0, "MPrice"); updateCommand.Parameters.Add("@ValidDate", SqlDbType.Date, 0, "ValidDate"); updateCommand.Parameters.Add("@SupplyNo", SqlDbType.Char, 10, "SupplyNo"); updateCommand.Parameters.AddWithValue("@StockNo", this.StockNo); updateCommand.Parameters.Add("@OldMNo", SqlDbType.Char, 10, "MNo"); updateCommand.Parameters["@OldMNo"].SourceVersion = DataRowVersion.Original; SqlCommand deleteCommand = new SqlCommand(); deleteCommand.Connection = sqlConnection; deleteCommand.CommandText = "Delete tb_medicine" + " WHERE MNo=@MNo;"; deleteCommand.Parameters.Add("@MNo", SqlDbType.Char, 10, "MNo"); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.InsertCommand = insertCommand; sqlDataAdapter.UpdateCommand = updateCommand; sqlDataAdapter.DeleteCommand = deleteCommand; DataTable medicineTable1 = (DataTable)this.dgv_Medicine.DataSource; sqlConnection.Open(); int rowAffected = sqlDataAdapter.Update(medicineTable1); sqlConnection.Close(); MessageBox.Show("更新" + rowAffected.ToString() + "行。"); lb_StockName.Text = "" + "本药库为" + this.StockName + "。" + "现存" + medicineTable1.Compute("Count(MNo)", "").ToString() + "种药品"; } } } }
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; using System.Data.SqlClient; using System.Configuration; namespace 药品信息管理系统 { public partial class frm_Supply : Form { TreeNode xinxinode = new TreeNode(); TreeNode jinhuonode = new TreeNode(); TreeNode chuhuonode = new TreeNode(); TreeNode kucunnode = new TreeNode(); TreeNode tongjinode = new TreeNode(); TreeNode xitongnode = new TreeNode(); TreeNode xinxinode_Client = new TreeNode(); TreeNode xinxinode_Supply = new TreeNode(); TreeNode xinxinode_Medicine = new TreeNode(); TreeNode jinhuoNode_caigou = new TreeNode(); TreeNode jinhuoNode_jiesuan = new TreeNode(); TreeNode jinhuoNode_ruku = new TreeNode(); TreeNode chuhuoNode_yuji = new TreeNode(); TreeNode qijianNode_caigou = new TreeNode(); TreeNode jiduNode_caigou = new TreeNode(); TreeNode kucunNode_youxiaoqi = new TreeNode(); TreeNode kukunNode_kucun = new TreeNode(); TreeNode kucunNode_yaoku = new TreeNode(); public frm_Supply() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; } private void btn_Go_Click(object sender, EventArgs e) { frm_SupplyTable frm_supplyTable = new frm_SupplyTable(); frm_supplyTable.ShowDialog(this); this.Hide(); } private void frm_Supply_Load(object sender, EventArgs e) { this.trv_Menu.BackColor = Color.AliceBlue; this.trv_Menu.SelectedNode = null; this.trv_Menu.ExpandAll(); //this.trv_Menu.SelectedNode = this.trv_Menu.Nodes[0]; //展开组件中的所有节点 //this.trv_Menu.SelectedNode.ExpandAll(); //this.trv_Menu.SelectedNode.Nodes .Add () //this.trv_Menu.Expanded = true; //this.trv_Menu.Nodes[1].Expand(); trv_Menu.LabelEdit = true;//可编辑状态。 //添加一个节点,这个结点是根节点。 xinxinode.Text = "信息维护"; xinxinode.Expand(); xinxinode.ImageIndex = 5; jinhuonode.Text = "进货管理"; jinhuonode.Expand(); jinhuonode.ImageIndex = 9; chuhuonode.Text = "出货管理"; chuhuonode.Expand(); chuhuonode.ImageIndex = 10; kucunnode.Text = "库存管理"; kucunnode.ImageIndex = 8; kucunnode.Expand(); tongjinode.Text = "采购统计"; tongjinode.ImageIndex = 3; xitongnode.Text = "系统设置"; xitongnode.ImageIndex = 7; //TreeNode node6 = new TreeNode(); //node6.Text = "库存管理"; trv_Menu.Nodes.Add(xinxinode); trv_Menu.Nodes.Add(jinhuonode); trv_Menu.Nodes.Add(chuhuonode); trv_Menu.Nodes.Add(kucunnode); trv_Menu.Nodes.Add(tongjinode); trv_Menu.Nodes.Add(xitongnode); //信息维护根节点下 xinxinode_Client.Text = "会员信息维护"; xinxinode_Client.ImageIndex = 2; xinxinode_Client.NodeFont = new Font("幼圆", 11); xinxinode_Supply.Text = "供应商信息维护"; xinxinode_Supply.ImageIndex = 1; xinxinode_Supply.NodeFont = new Font("幼圆", 11); xinxinode_Supply.BackColor = Color.Red; xinxinode_Medicine.Text = "药品信息维护"; xinxinode_Medicine.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.ImageIndex = 6; xinxinode.Nodes.Add(xinxinode_Client); xinxinode.Nodes.Add(xinxinode_Supply); xinxinode.Nodes.Add(xinxinode_Medicine); //进货管理根节点下 jinhuoNode_caigou.Text = "采集药品"; jinhuoNode_caigou.NodeFont = new Font("幼圆", 11); jinhuoNode_jiesuan.Text = "订单结算审核"; jinhuoNode_jiesuan.NodeFont = new Font("幼圆", 11); jinhuoNode_ruku.Text = "药品审核入库"; jinhuoNode_ruku.NodeFont = new Font("幼圆", 11); jinhuonode.Nodes.Add(jinhuoNode_caigou); jinhuonode.Nodes.Add(jinhuoNode_jiesuan); jinhuonode.Nodes.Add(jinhuoNode_ruku); //出货管理根节点下 chuhuoNode_yuji.Text = "出售药品"; chuhuoNode_yuji.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_shoukuan = new TreeNode(); //chuhuoNode_shoukuan.Text = "收款审核"; //chuhuoNode_shoukuan.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_chuku = new TreeNode(); //chuhuoNode_chuku.Text = "药品审核出库"; //chuhuoNode_chuku.NodeFont = new Font("幼圆", 11); chuhuonode.Nodes.Add(chuhuoNode_yuji); //chuhuonode.Nodes.Add(chuhuoNode_shoukuan); //chuhuonode.Nodes.Add(chuhuoNode_chuku); //统计管理根节点下 qijianNode_caigou.Text = "期间统计分析"; qijianNode_caigou.NodeFont = new Font("幼圆", 11); jiduNode_caigou.Text = "季度统计分析"; jiduNode_caigou.NodeFont = new Font("幼圆", 11); tongjinode.Nodes.Add(jiduNode_caigou); tongjinode.Nodes.Add(qijianNode_caigou); //库存管理根节点下 kucunNode_youxiaoqi.Text = "有效期提示"; kucunNode_youxiaoqi.NodeFont = new Font("幼圆", 11); kucunNode_youxiaoqi.ImageIndex = 4; kukunNode_kucun.Text = "库存量查询"; kukunNode_kucun.NodeFont = new Font("幼圆", 11); kucunNode_yaoku.Text = "药库管理"; kucunNode_yaoku.NodeFont = new Font("幼圆", 11); kucunnode.Nodes.Add(kucunNode_youxiaoqi); kucunnode.Nodes.Add(kukunNode_kucun); kucunnode.Nodes.Add(kucunNode_yaoku); //this.trv_Menu.CheckBoxes = true; this.trv_Menu.ExpandAll(); 管理员ToolStripMenuItem.Text = frm_LogIn.AdminName.ToString(); } private void btn_SSeek_Click_1(object sender, EventArgs e) { if (cb_LoadName.Checked == false && cb_LoadNo.Checked == false) { MessageBox.Show("请勾选查询方式"); } if (cb_LoadNo.Checked) { this.txt_SNO.Text = this.cob_SupplyNo.Text; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand1 = sqlConnection.CreateCommand(); sqlCommand1.CommandText = "select SupplyNo,SupplyName,Address ,SupplyTel, dbo.fn_GetPy(SupplyName)as pymc from tb_Supply where SupplyNo=@SupplyNo"; sqlCommand1.Parameters.AddWithValue("@SupplyNo", this.cob_SupplyNo.Text.ToString()); sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand1.ExecuteReader(); while (sqlDataReader.Read()) { //this.txt_SNO.Text = sqlDataReader["SupplyNO"].ToString(); this.txt_SName.Text = sqlDataReader["SupplyName"].ToString(); this.txt_STel.Text = sqlDataReader["SupplyTel"].ToString(); this.txt_SAddress.Text = sqlDataReader["Address"].ToString(); //this.txt_pinyin.Text = sqlDataReader["pymc"].ToString(); } sqlDataReader.Close(); sqlConnection.Close(); } } else if (cb_LoadName.Checked) { this.txt_SName.Text = this.cob_Name.Text; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand1 = sqlConnection.CreateCommand(); sqlCommand1.CommandText = "select SupplyNo,SupplyName,Address ,SupplyTel, dbo.fn_GetPy(SupplyName)as pymc from tb_Supply where SupplyName in (select SupplyName from tb_Supply where SupplyName like '%" + this.cob_Name.Text.ToString() + "%')"; //指定SQL命令的命令文本;命令文本为存储过程名称; sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand1.ExecuteReader(); while (sqlDataReader.Read()) { this.txt_SNO.Text = sqlDataReader["SupplyNO"].ToString(); //this.txt_CName.Text = sqlDataReader["CName"].ToString(); this.txt_STel.Text = sqlDataReader["SupplyTel"].ToString(); this.txt_SAddress.Text = sqlDataReader["Address"].ToString(); //this.txt_pinyin.Text = sqlDataReader["pymc"].ToString(); } sqlDataReader.Close(); sqlConnection.Close(); } } } private void btn_Sadd_Click(object sender, EventArgs e) { btn_Sadd.Enabled = false; btn_Save.Enabled = true; ; gb_SupplyManage.Text = "添加供应商信息"; } private void btn_Salter_Click(object sender, EventArgs e) { btn_Salter.Enabled = false; btn_Save.Enabled = true; gb_SupplyManage.Text = "修改供应商信息"; } private void btn_SDelete_Click(object sender, EventArgs e) { btn_SDelete.Enabled = false; btn_Save.Enabled = true; gb_SupplyManage.Text = "删除供应商信息"; } private void cb_LoadNo_CheckedChanged(object sender, EventArgs e) { if(cb_LoadName .Checked ==false ) { if(cb_LoadNo .Checked ==false ) { cob_Name .Text =""; cob_SupplyNo .Text =""; } } if (cb_LoadNo.Checked) { cb_LoadName.Checked = false; txt_SName.ReadOnly = false; cob_Name.Text = ""; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = sqlConnection.CreateCommand(); sqlCommand.CommandText = "select SupplyNo from tb_Supply"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; DataTable SupplyTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(SupplyTable); this.cob_SupplyNo.DataSource = SupplyTable; this.cob_SupplyNo.DisplayMember = "SupplyNo"; this.cob_SupplyNo.ValueMember = "SupplyNo"; SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { this.cob_SupplyNo.Text = sqlDataReader["SupplyNo"].ToString(); } sqlDataReader.Close(); sqlConnection.Close(); } } } private void cb_LoadName_CheckedChanged(object sender, EventArgs e) { if (cb_LoadName.Checked == false) { if (cb_LoadNo.Checked == false) { cob_Name.Text = ""; cob_SupplyNo.Text = ""; } } if (cb_LoadName.Checked) { cb_LoadNo.Checked = false; //txt_SName.ReadOnly = true; cob_SupplyNo.Text = ""; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = sqlConnection.CreateCommand(); sqlCommand.CommandText = "select SupplyName from tb_Supply"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; DataTable SupplyTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(SupplyTable); this.cob_Name.DataSource = SupplyTable; this.cob_Name.DisplayMember = "SupplyName"; this.cob_Name.ValueMember = "SupplyName"; SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { this.cob_Name.Text = sqlDataReader["SupplyName"].ToString(); } sqlDataReader.Close(); sqlConnection.Close(); } } } private void btn_Load_Click(object sender, EventArgs e) { cob_SupplyNo.Text = ""; cob_Name.Text = ""; txt_SAddress.Text = ""; txt_SName.Text = ""; txt_SNO.Text = ""; txt_STel.Text = ""; //txt_pinyin.Text = "填写名称拼音缩写"; //txt_pinyin.SelectAll(); } private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); } private void btn_Save_Click(object sender, EventArgs e) { if (btn_Sadd.Enabled == false) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { sqlConnection.Open(); string str = " insert tb_Supply (SupplyNO ,SupplyName ,Address ,SupplyTel )values('" + this.txt_SNO.Text + "','" + this.txt_SName.Text + "','" + this.txt_SAddress.Text + "','" + this.txt_STel.Text + "')"; SqlCommand sqlCommand1 = new SqlCommand(str, sqlConnection); //sqlConnection.Open(); int i = 0; try { i = sqlCommand1.ExecuteNonQuery(); } catch (SqlException sqlEx) { if (sqlEx.Number == 2627) { i = 0; MessageBox.Show("客户已存在"); } else { throw sqlEx; } }//打开SQL连接; if (i == 1) { MessageBox.Show("添加成功"); } else MessageBox.Show("添加失败"); sqlConnection.Close(); } btn_Save.Enabled = false; btn_Sadd.Enabled = true; } if (btn_SDelete.Enabled == false) { if (MessageBox.Show("确认删除编号为" + txt_SNO.Text + "的数据?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { sqlConnection.Open(); string str = "delete from tb_Supply where SupplyNO='" + this.txt_SNO.Text + "'"; SqlCommand sqlCommand1 = new SqlCommand(str, sqlConnection); //sqlConnection.Open(); int i = sqlCommand1.ExecuteNonQuery(); if (i == 1) { MessageBox.Show("删除成功"); } else MessageBox.Show("删除失败"); sqlConnection.Close(); } cob_SupplyNo.Text = ""; cob_Name.Text = ""; txt_SAddress.Text = ""; txt_SName.Text = ""; txt_SNO.Text = ""; txt_STel.Text = ""; //txt_pinyin.Text = "填写名称拼音缩写"; //txt_pinyin.SelectAll(); btn_SDelete.Enabled = true; btn_Save.Enabled = false; } if (btn_Salter.Enabled == false) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { sqlConnection.Open(); string str = "update tb_Supply set SupplyName='" + this.txt_SName.Text + "',SupplyTel='" + this.txt_STel.Text + "',Address='" + this.txt_SAddress.Text + "' where SupplyNO='" + this.txt_SNO.Text + "'"; SqlCommand sqlCommand1 = new SqlCommand(str, sqlConnection); //sqlConnection.Open(); int i = sqlCommand1.ExecuteNonQuery(); if (i == 1) { MessageBox.Show("更新成功"); } else MessageBox.Show("更新失败"); sqlConnection.Close(); } btn_Salter.Enabled = true; btn_Save.Enabled = false; } } } private void gb_SupplyManage_Enter(object sender, EventArgs e) { } private void trv_Menu_AfterSelect(object sender, TreeViewEventArgs e) { if (this.trv_Menu.SelectedNode == xinxinode_Client) { this.Hide(); frm_Client f = new frm_Client(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Supply) { this.Hide(); frm_Supply f = new frm_Supply(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Medicine) { this.Hide(); medicine f = new medicine(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_caigou) { this.Hide(); frm_caigou f = new frm_caigou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_jiesuan) { this.Hide(); frm_caigouOrder f = new frm_caigouOrder(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_ruku) { this.Hide(); frm_caigouStored f = new frm_caigouStored(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == chuhuoNode_yuji) { this.Hide(); frm_chushou f = new frm_chushou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == qijianNode_caigou) { this.Hide(); frm_Analysis_qijian f = new frm_Analysis_qijian(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jiduNode_caigou) { this.Hide(); frm_Analysis f = new frm_Analysis(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_youxiaoqi) { this.Hide(); frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kukunNode_kucun) { this.Hide(); frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_yaoku) { this.Hide(); frm_Stock f = new frm_Stock(); f.ShowDialog(this); } } private void person_Click(object sender, EventArgs e) { this.Hide(); personnel p = new personnel(); p.ShowDialog(this); } private void 退出登录ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("确认退出本系统?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Application.Exit(); } } private void 修改密码_Click(object sender, EventArgs e) { this.Hide(); frm_FindPwd f = new frm_FindPwd(); f.ShowDialog(this); } private void gb_Supply_Enter(object sender, EventArgs e) { } } }
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; using System.Data.SqlClient; using System.Configuration; namespace 药品信息管理系统 { public partial class frm_SupplyTable : Form { private DataTable SuppplyTable; public frm_SupplyTable() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; //this.dgv_SupplyTable.AllowUserToAddRows = true; this.dgv_Supply.RowHeadersVisible = true; this.dgv_Supply.BackgroundColor = Color.White; this.dgv_Supply.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Supply.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv_Supply.ColumnHeadersHeight = 30; dgv_Supply.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Supply.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 10, FontStyle.Bold); dgv_Supply.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Supply.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Supply.ColumnHeadersDefaultCellStyle.ForeColor = ColorTranslator.FromHtml("#fff"); dgv_Supply.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Supply.GridColor = ColorTranslator.FromHtml("#006CB3"); dgv_Supply.BackgroundColor = ColorTranslator.FromHtml("#E7F5FF"); dgv_Supply.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Supply.RowHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Supply.RowTemplate.Height = 30; dgv_Supply.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Supply.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#97D5FF"); dgv_Supply.AlternatingRowsDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#E1F3FF"); } private void frm_SupplyTable_Load_1(object sender, EventArgs e) { 管理员ToolStripMenuItem.Text = frm_LogIn.AdminName.ToString(); } private void btn_Load_Click_1(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); //SqlCommand sqlcommand1 = new SqlCommand(); //SqlCommand sqlCommand2 = new SqlCommand(); sqlCommand.Connection = sqlConnection; //sqlcommand1.Connection = sqlConnection; //sqlCommand2.Connection = sqlConnection; sqlCommand.CommandText = "select SupplyNo,SupplyName,Address ,SupplyTel, dbo.fn_GetPy(SupplyName)as pymc from tb_Supply ;"; //sqlcommand1.CommandText = "SELECT * FROM Tb_Stock"; //sqlCommand2.CommandText = "SELECT * FROM tb_medicine;"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; this.SuppplyTable = new DataTable(); //this.SupplyTable = new DataTable(); //SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); //sqlDataAdapter1.SelectCommand = sqlcommand1; //DataTable StockTable = new DataTable(); //SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); //sqlDataAdapter2.SelectCommand = sqlCommand2; //DataTable medicineTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(this.SuppplyTable ); //sqlDataAdapter1.Fill(StockTable); //sqlDataAdapter2.Fill(medicineTable); sqlConnection.Close(); this.dgv_Supply.Columns.Clear(); this.dgv_Supply.DataSource = this.SuppplyTable ; this.dgv_Supply .Columns["SupplyNo"].HeaderText = "供应商编号"; this.dgv_Supply .Columns["SupplyName"].HeaderText = "供应商名称"; this.dgv_Supply .Columns["Address"].HeaderText = "地址"; this.dgv_Supply.Columns["SupplyTel"].HeaderText = "联系电话"; this.dgv_Supply.Columns["pymc"].Visible = false; this.dgv_Supply .Columns[this.dgv_Supply .Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } private void btn_Submit_Click_1(object sender, EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand insertCommand = new SqlCommand(); insertCommand.Connection = sqlConnection; insertCommand.CommandText = "insert tb_Supply (SupplyNo,SupplyName,SupplyTel,Address)values" + " (@SupplyNo,@SupplyName,@SupplyTel,@Address)"; insertCommand.Parameters.Add("@SupplyName", SqlDbType.VarChar, 0, "SupplyName"); insertCommand.Parameters.Add("@Address", SqlDbType.VarChar, 0, "Address"); insertCommand.Parameters.Add("@SupplyTel", SqlDbType.VarChar, 0, "SupplyTel"); insertCommand.Parameters.Add("@SupplyNo", SqlDbType.Char, 10, "SupplyNo"); SqlCommand updateCommand = new SqlCommand(); updateCommand.Connection = sqlConnection; updateCommand.CommandText = "UPDATE tb_Supply" + " SET SupplyNo=@NewSupplyNo,SupplyName=@SupplyName,Address=@Address,SupplyTel=@SupplyTel" + " WHERE SupplyNo=@OldSupplyNo;"; updateCommand.Parameters.Add("@NewSupplyNo", SqlDbType.Char, 10, "SupplyNo"); updateCommand.Parameters.Add("@SupplyName", SqlDbType.VarChar, 0, "SupplyName"); updateCommand.Parameters.Add("@Address", SqlDbType.VarChar, 0, "Address"); updateCommand.Parameters.Add("@SupplyTel", SqlDbType.VarChar, 0, "SupplyTel"); updateCommand.Parameters.Add("@OldSupplyNo", SqlDbType.Char, 10, "SupplyNo"); updateCommand.Parameters["@OldSupplyNo"].SourceVersion = DataRowVersion.Original; SqlCommand deleteCommand = new SqlCommand(); deleteCommand.Connection = sqlConnection; deleteCommand.CommandText = "delete tb_Supply" + " WHERE SupplyNo=@SupplyNo;"; deleteCommand.Parameters.Add("@SupplyNo", SqlDbType.Char, 10, "SupplyNo"); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.InsertCommand = insertCommand; sqlDataAdapter.UpdateCommand = updateCommand; sqlDataAdapter.DeleteCommand = deleteCommand; DataTable supplyTable1 = (DataTable)this.dgv_Supply .DataSource; sqlConnection.Open(); int rowAffected = sqlDataAdapter.Update(supplyTable1); sqlConnection.Close(); MessageBox.Show("更新" + rowAffected.ToString() + "行。"); } } private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); } private void txt_Pinyin_TextChanged(object sender, EventArgs e) { if (dgv_Supply.DataSource == null) { MessageBox.Show("请先点击“载入”载入供应商数据"); txt_Pinyin.Text = ""; txt_Pinyin.Focus(); } else { DataRow[] searchResultRows = this.SuppplyTable.Select("pymc LIKE '%" + this.txt_Pinyin.Text.Trim() + "%'"); DataTable searchResultTable = this.SuppplyTable.Clone(); foreach (DataRow row in searchResultRows) { searchResultTable.ImportRow(row); } this.dgv_Supply.DataSource = searchResultTable; } } private void 个人设置ToolStripMenuItem_Click(object sender, EventArgs e) { frm_FindPwd f = new frm_FindPwd(); f.ShowDialog(this); } private void 联系我们ToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("致电谢雪妮:15060120822"); } } }
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; using System.Data.SqlClient; using System.Configuration; using System.IO; //包含输入输出对象; using System.Drawing.Imaging; namespace 药品信息管理系统 { public partial class medicine : Form { TreeNode xinxinode = new TreeNode(); TreeNode jinhuonode = new TreeNode(); TreeNode chuhuonode = new TreeNode(); TreeNode kucunnode = new TreeNode(); TreeNode tongjinode = new TreeNode(); TreeNode xitongnode = new TreeNode(); TreeNode xinxinode_Client = new TreeNode(); TreeNode xinxinode_Supply = new TreeNode(); TreeNode xinxinode_Medicine = new TreeNode(); TreeNode jinhuoNode_caigou = new TreeNode(); TreeNode jinhuoNode_jiesuan = new TreeNode(); TreeNode jinhuoNode_ruku = new TreeNode(); TreeNode chuhuoNode_yuji = new TreeNode(); TreeNode qijianNode_caigou = new TreeNode(); TreeNode jiduNode_caigou = new TreeNode(); TreeNode kucunNode_youxiaoqi = new TreeNode(); TreeNode kukunNode_kucun = new TreeNode(); TreeNode kucunNode_yaoku = new TreeNode(); private string PhotoFileName; public medicine() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; //本窗体启动位置设为屏幕中央; } private void medicine_Load(object sender, EventArgs e) { this.trv_Menu.BackColor = Color.AliceBlue; this.trv_Menu.SelectedNode = null; this.trv_Menu.ExpandAll(); //this.trv_Menu.SelectedNode = this.trv_Menu.Nodes[0]; //展开组件中的所有节点 //this.trv_Menu.SelectedNode.ExpandAll(); //this.trv_Menu.SelectedNode.Nodes .Add () //this.trv_Menu.Expanded = true; //this.trv_Menu.Nodes[1].Expand(); trv_Menu.LabelEdit = true;//可编辑状态。 //添加一个节点,这个结点是根节点。 xinxinode.Text = "信息维护"; xinxinode.Expand(); xinxinode.ImageIndex = 5; jinhuonode.Text = "进货管理"; jinhuonode.Expand(); jinhuonode.ImageIndex = 9; chuhuonode.Text = "出货管理"; chuhuonode.Expand(); chuhuonode.ImageIndex = 10; kucunnode.Text = "库存管理"; kucunnode.ImageIndex = 8; kucunnode.Expand(); tongjinode.Text = "采购统计"; tongjinode.ImageIndex = 3; xitongnode.Text = "系统设置"; xitongnode.ImageIndex = 7; //TreeNode node6 = new TreeNode(); //node6.Text = "库存管理"; trv_Menu.Nodes.Add(xinxinode); trv_Menu.Nodes.Add(jinhuonode); trv_Menu.Nodes.Add(chuhuonode); trv_Menu.Nodes.Add(kucunnode); trv_Menu.Nodes.Add(tongjinode); trv_Menu.Nodes.Add(xitongnode); //信息维护根节点下 xinxinode_Client.Text = "会员信息维护"; xinxinode_Client.ImageIndex = 2; xinxinode_Client.NodeFont = new Font("幼圆", 11); xinxinode_Supply.Text = "供应商信息维护"; xinxinode_Supply.ImageIndex = 1; xinxinode_Supply.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.Text = "药品信息维护"; xinxinode_Medicine.NodeFont = new Font("幼圆", 11); xinxinode_Medicine.ImageIndex = 6; xinxinode_Medicine.BackColor = Color.Red; xinxinode.Nodes.Add(xinxinode_Client); xinxinode.Nodes.Add(xinxinode_Supply); xinxinode.Nodes.Add(xinxinode_Medicine); //进货管理根节点下 jinhuoNode_caigou.Text = "采集药品"; jinhuoNode_caigou.NodeFont = new Font("幼圆", 11); jinhuoNode_jiesuan.Text = "订单结算审核"; jinhuoNode_jiesuan.NodeFont = new Font("幼圆", 11); jinhuoNode_ruku.Text = "药品审核入库"; jinhuoNode_ruku.NodeFont = new Font("幼圆", 11); jinhuonode.Nodes.Add(jinhuoNode_caigou); jinhuonode.Nodes.Add(jinhuoNode_jiesuan); jinhuonode.Nodes.Add(jinhuoNode_ruku); //出货管理根节点下 chuhuoNode_yuji.Text = "出售药品"; chuhuoNode_yuji.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_shoukuan = new TreeNode(); //chuhuoNode_shoukuan.Text = "收款审核"; //chuhuoNode_shoukuan.NodeFont = new Font("幼圆", 11); //TreeNode chuhuoNode_chuku = new TreeNode(); //chuhuoNode_chuku.Text = "药品审核出库"; //chuhuoNode_chuku.NodeFont = new Font("幼圆", 11); chuhuonode.Nodes.Add(chuhuoNode_yuji); //chuhuonode.Nodes.Add(chuhuoNode_shoukuan); //chuhuonode.Nodes.Add(chuhuoNode_chuku); //统计管理根节点下 qijianNode_caigou.Text = "期间统计分析"; qijianNode_caigou.NodeFont = new Font("幼圆", 11); jiduNode_caigou.Text = "季度统计分析"; jiduNode_caigou.NodeFont = new Font("幼圆", 11); tongjinode.Nodes.Add(jiduNode_caigou); tongjinode.Nodes.Add(qijianNode_caigou); //库存管理根节点下 kucunNode_youxiaoqi.Text = "有效期提示"; kucunNode_youxiaoqi.NodeFont = new Font("幼圆", 11); kucunNode_youxiaoqi.ImageIndex = 4; kukunNode_kucun.Text = "库存量查询"; kukunNode_kucun.NodeFont = new Font("幼圆", 11); kucunNode_yaoku.Text = "药库管理"; kucunNode_yaoku.NodeFont = new Font("幼圆", 11); kucunnode.Nodes.Add(kucunNode_youxiaoqi); kucunnode.Nodes.Add(kukunNode_kucun); kucunnode.Nodes.Add(kucunNode_yaoku); //this.trv_Menu.CheckBoxes = true; this.trv_Menu.ExpandAll(); 管理员ToolStripMenuItem.Text = frm_LogIn.AdminName.ToString(); //this.txt_pinyin.SelectAll();// TODO: 这行代码将数据加载到表“medicineDataSet1.tb_medicine”中。您可以根据需要移动或移除它。 //this.tb_medicineTableAdapter.Fill(this.medicineDataSet1.tb_medicine); using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand2 = new SqlCommand(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand2.Connection = sqlConnection; sqlCommand.Connection = sqlConnection; sqlCommand2.CommandText = "select * from tb_Supply"; sqlCommand.CommandText = "select * from Tb_Stock"; SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter2.SelectCommand = sqlCommand2; sqlDataAdapter.SelectCommand = sqlCommand; DataTable SupplyTable = new DataTable(); DataTable StockTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter2.Fill(SupplyTable); this.cob_Supply.DataSource = SupplyTable; this.cob_Supply.DisplayMember = "SupplyName"; this.cob_Supply.ValueMember = "SupplyNo"; SqlDataReader sqlDataReader2 = sqlCommand2.ExecuteReader(); while (sqlDataReader2.Read()) { this.cob_Supply.SelectedValue = sqlDataReader2["SupplyNo"]; } sqlDataReader2.Close(); sqlDataAdapter.Fill(StockTable); this.cob_Stock.DataSource = StockTable; this.cob_Stock.DisplayMember = "StockName"; this.cob_Stock.ValueMember = "StockNo"; SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { this.cob_Stock.SelectedValue = sqlDataReader["StockNo"]; } sqlDataReader.Close(); sqlConnection.Close(); } } private void btn_update1_Click(object sender, EventArgs e) { btn_update1.Enabled = false; btn_save.Enabled = true; gb_medicineManage .Text= "修改药品信息"; } private void btn_Go_Click(object sender, EventArgs e) { frm_MedicineTable frm_medicineTable = new frm_MedicineTable(); frm_medicineTable.ShowDialog(this); this.Hide(); } private void btn_OpenPhoto_Click(object sender, EventArgs e) { OpenFileDialog openPhotoDialog = new OpenFileDialog() { Title = "打开照片文件(位图格式)" , Filter = "BMP Files (*.bmp)|*.bmp" , InitialDirectory = @"C:\" }; if (openPhotoDialog.ShowDialog() == DialogResult.OK) { this.PhotoFileName = openPhotoDialog.FileName; this.ptb_Photo.Image = Image.FromFile(this.PhotoFileName); } } private void btn_Add_Click(object sender, EventArgs e) { btn_Add.Enabled = false; btn_save.Enabled = true; gb_medicineManage.Text = "添加药品信息"; } private void btn_Delete_Click(object sender, EventArgs e) { btn_Delete.Enabled = false; btn_save.Enabled = true; gb_medicineManage.Text = "删除药品信息"; //MemoryStream memoryStream = new MemoryStream(); //this.ptb_Photo.Image.Save(memoryStream, ImageFormat.Bmp); //byte[] photoBytes = new byte[memoryStream.Length]; //memoryStream.Seek(0, SeekOrigin.Begin); //memoryStream.Read(photoBytes, 0, photoBytes.Length); } private void cb_LoadNo_CheckedChanged(object sender, EventArgs e) { if (cb_LoadName.Checked == false && cb_LoadNo.Checked == false) { cob_medicine.Text = ""; cob_name.Text = ""; } if (cb_LoadNo.Checked) { cb_LoadName.Checked = false; txt_MName.ReadOnly = false; cob_name.Text = ""; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand4 = sqlConnection.CreateCommand(); sqlCommand4.CommandText = "select MNo from tb_medicine"; SqlDataAdapter sqlDataAdapter4 = new SqlDataAdapter(); sqlDataAdapter4.SelectCommand = sqlCommand4; DataTable medicineTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter4.Fill(medicineTable); this.cob_medicine.DataSource = medicineTable; this.cob_medicine.DisplayMember = "MNo"; this.cob_medicine.ValueMember = "MNo"; SqlDataReader sqlDataReader4 = sqlCommand4.ExecuteReader(); while (sqlDataReader4.Read()) { this.cob_medicine.Text = sqlDataReader4["MNo"].ToString(); } sqlDataReader4.Close(); sqlConnection.Close(); } } } private void cb_LoadName_CheckedChanged(object sender, EventArgs e) { if (cb_LoadName.Checked == false && cb_LoadNo.Checked == false) { cob_medicine.Text = ""; cob_name.Text = ""; } if (cb_LoadName.Checked) { cb_LoadNo.Checked = false; //txt_MName.ReadOnly = true; cob_medicine.Text = ""; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = sqlConnection.CreateCommand(); SqlCommand sqlCommand4 = sqlConnection.CreateCommand(); sqlCommand.CommandText = "select "; sqlCommand4.CommandText = "select MName from tb_medicine"; SqlDataAdapter sqlDataAdapter4 = new SqlDataAdapter(); sqlDataAdapter4.SelectCommand = sqlCommand4; DataTable medicineTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter4.Fill(medicineTable); this.cob_name.DataSource = medicineTable; this.cob_name.DisplayMember = "MName"; this.cob_name.ValueMember = "MName"; SqlDataReader sqlDataReader4 = sqlCommand4.ExecuteReader(); while (sqlDataReader4.Read()) { this.cob_name.Text = sqlDataReader4["MName"].ToString(); } sqlDataReader4.Close(); sqlConnection.Close(); } } } private void btn_SEEK_Click(object sender, EventArgs e) { if (rdb_OTC.Checked == false) { rdb_Rx.Checked = true; } if(cb_LoadNo .Checked ) { this.txt_MNo.Text = this.cob_medicine.Text; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand1 = sqlConnection.CreateCommand(); sqlCommand1.CommandText = "select * from tb_medicine where MNo=@MNo"; sqlCommand1.Parameters.AddWithValue("@MNo", this.cob_medicine.Text.ToString());// //sqlCommand1.CommandType = CommandType.StoredProcedure; SqlCommand sqlCommand2 = new SqlCommand(); sqlCommand2.Connection = sqlConnection; sqlCommand2.CommandText = "select * from tb_Supply"; SqlCommand sqlCommand3 = new SqlCommand(); sqlCommand3.Connection = sqlConnection; sqlCommand3.CommandText = "select * from Tb_Stock"; //sqlCommand1.Parameters.AddWithValue("@MNo", this .txt_MNo .Text .ToString ()); //SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); //sqlDataAdapter1.SelectCommand = sqlCommand1; //DataTable medicinetable = new DataTable(); SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); sqlDataAdapter2.SelectCommand = sqlCommand2; DataTable SupplyTable = new DataTable(); SqlDataAdapter sqlDataAdapter3 = new SqlDataAdapter(); sqlDataAdapter3.SelectCommand = sqlCommand3; DataTable StockTable = new DataTable();//向SQL命令的参数集合添加参数的名称、值; sqlConnection.Open(); //sqlDataAdapter1 .Fill (medicinetable ); //this.cob_medicine.DataSource = medicinetable; //this.cob_medicine.DisplayMember = "MName"; //this.cob_Supply.ValueMember = "MNo"; sqlDataAdapter2.Fill(SupplyTable); this.cob_Supply.DataSource = SupplyTable; this.cob_Supply.DisplayMember = "SupplyName"; this.cob_Supply.ValueMember = "SupplyNo"; sqlDataAdapter3.Fill(StockTable); this.cob_Stock.DataSource = StockTable; this.cob_Stock.DisplayMember = "StockName"; this.cob_Stock.ValueMember = "StockNo"; SqlDataReader sqlDataReader = sqlCommand1.ExecuteReader(); byte[] photoBytes = null; while (sqlDataReader.Read()) { this.txt_MName.Text = sqlDataReader["MName"].ToString(); this.rdb_OTC.Checked = (bool)sqlDataReader["IsOTC"]; this.txt_MPrice.Text = sqlDataReader["MPrice"].ToString(); //this.txt_MNum.Text = sqlDataReader["MNum"].ToString(); this.txt_norm.Text = sqlDataReader["Norm"].ToString(); this.dtp_ValidDate.Value = (DateTime)sqlDataReader["ValidDate"]; this.cob_Supply.SelectedValue = sqlDataReader["SupplyNo"]; this.cob_Stock.SelectedValue = sqlDataReader["StockNo"]; //this.txt_pinyin.Text = sqlDataReader["pinyin"].ToString(); this.txt_Instruction.Text = sqlDataReader["Instuction"].ToString(); photoBytes = (sqlDataReader["Photo"] == DBNull.Value ? null : (byte[])sqlDataReader["Photo"]); } sqlDataReader.Close(); sqlConnection.Close(); if (photoBytes != null) { MemoryStream memoryStream = new MemoryStream(photoBytes); this.ptb_Photo.Image = Image.FromStream(memoryStream); } } } else if (cb_LoadName.Checked) { this.txt_MName.Text = this.cob_name.Text; using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand1 = sqlConnection.CreateCommand(); sqlCommand1.CommandText = "select * from tb_medicine where MName=@MName"; sqlCommand1.Parameters.AddWithValue("@MName", this.cob_name.Text.ToString());// //sqlCommand1.CommandType = CommandType.StoredProcedure; SqlCommand sqlCommand2 = new SqlCommand(); sqlCommand2.Connection = sqlConnection; sqlCommand2.CommandText = "select * from tb_Supply"; SqlCommand sqlCommand3 = new SqlCommand(); sqlCommand3.Connection = sqlConnection; sqlCommand3.CommandText = "select * from Tb_Stock"; //sqlCommand1.Parameters.AddWithValue("@MNo", this .txt_MNo .Text .ToString ()); //SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter(); //sqlDataAdapter1.SelectCommand = sqlCommand1; //DataTable medicinetable = new DataTable(); SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(); sqlDataAdapter2.SelectCommand = sqlCommand2; DataTable SupplyTable = new DataTable(); SqlDataAdapter sqlDataAdapter3 = new SqlDataAdapter(); sqlDataAdapter3.SelectCommand = sqlCommand3; DataTable StockTable = new DataTable(); sqlConnection.Open(); //sqlDataAdapter1 .Fill (medicinetable ); //this.cob_medicine.DataSource = medicinetable; //this.cob_medicine.DisplayMember = "MName"; //this.cob_Supply.ValueMember = "MNo"; sqlDataAdapter2.Fill(SupplyTable); this.cob_Supply.DataSource = SupplyTable; this.cob_Supply.DisplayMember = "SupplyName"; this.cob_Supply.ValueMember = "SupplyNo"; sqlDataAdapter3.Fill(StockTable); this.cob_Stock.DataSource = StockTable; this.cob_Stock.DisplayMember = "StockName"; this.cob_Stock.ValueMember = "StockNo"; SqlDataReader sqlDataReader = sqlCommand1.ExecuteReader(); byte[] photoBytes = null; while (sqlDataReader.Read()) { this.txt_MNo.Text = sqlDataReader["MNo"].ToString(); this.rdb_OTC.Checked = (bool)sqlDataReader["IsOTC"]; this.txt_MPrice.Text = sqlDataReader["MPrice"].ToString(); //this.txt_MNum.Text = sqlDataReader["MNum"].ToString(); this.txt_norm.Text = sqlDataReader["Norm"].ToString(); this.dtp_ValidDate.Value = (DateTime)sqlDataReader["ValidDate"]; this.cob_Supply.SelectedValue = sqlDataReader["SupplyNo"]; this.cob_Stock.SelectedValue = sqlDataReader["StockNo"]; //this.txt_pinyin.Text = sqlDataReader["pinyin"].ToString(); this.txt_Instruction.Text = sqlDataReader["Instuction"].ToString(); photoBytes = (sqlDataReader["Photo"] == DBNull.Value ? null : (byte[])sqlDataReader["Photo"]); } sqlDataReader.Close(); sqlConnection.Close(); if (photoBytes != null) { MemoryStream memoryStream = new MemoryStream(photoBytes); this.ptb_Photo.Image = Image.FromStream(memoryStream); } } } } private void btn_Load_Click(object sender, EventArgs e) { txt_Instruction.Clear(); txt_MName.Clear(); txt_MNo.Clear(); //txt_MNum.Clear(); txt_MPrice.Clear(); txt_norm.Clear(); rdb_OTC.Checked = false; rdb_Rx.Checked = false; ptb_Photo.Image = null; //txt_pinyin.Text = "填写名称拼音缩写"; //txt_pinyin.SelectAll(); } private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); } private void btn_save_Click(object sender, EventArgs e) { if (btn_Add.Enabled == false) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { if (ptb_Photo.Image == null || txt_MNo.Text =="" || txt_MName.Text ==""|| txt_MPrice .Text =="") { MessageBox.Show("请务必添加药品图片,药品编号,药品名称及药品单价"); } else { MemoryStream memoryStream = new MemoryStream(); this.ptb_Photo.Image.Save(memoryStream, ImageFormat.Bmp); byte[] photoBytes = new byte[memoryStream.Length]; memoryStream.Seek(0, SeekOrigin.Begin); memoryStream.Read(photoBytes, 0, photoBytes.Length); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "insert tb_medicine " + " (MNo,MName,IsOTC,Norm,MPrice,ValidDate,SupplyNo,StockNo,Instuction ,Photo) " + " values (@MNo,@MName,@IsOTC,@Norm,@MPrice,@ValidDate,@SupplyNo,@StockNo,@Instuction ,@Photo);"; sqlCommand.Parameters.AddWithValue("@MName", this.txt_MName.Text.Trim()); sqlCommand.Parameters.AddWithValue("@IsOTC", this.rdb_OTC.Checked); //sqlCommand.Parameters.AddWithValue("@MNum", this.txt_MNum.Text.Trim()); sqlCommand.Parameters.AddWithValue("@Norm", this.txt_norm.Text.Trim()); sqlCommand.Parameters.AddWithValue("@MPrice", this.txt_MPrice.Text.Trim()); sqlCommand.Parameters.AddWithValue("@ValidDate", this.dtp_ValidDate.Value); sqlCommand.Parameters.AddWithValue("@SupplyNo", this.cob_Supply.SelectedValue); sqlCommand.Parameters.AddWithValue("@StockNo", this.cob_Stock.SelectedValue); sqlCommand.Parameters.AddWithValue("@Instuction", this.txt_Instruction.Text.Trim()); //sqlCommand.Parameters.AddWithValue("@pinyin", this.txt_pinyin.Text.Trim()); sqlCommand.Parameters.AddWithValue("@Photo", photoBytes); sqlCommand.Parameters.AddWithValue("@MNo", this.txt_MNo.Text.Trim()); sqlConnection.Open(); int i = 0; try { i = sqlCommand.ExecuteNonQuery(); } catch (SqlException sqlEx) { if (sqlEx.Number == 2627) { i = 0; MessageBox.Show("药品已存在"); } else { throw sqlEx; } }//打开SQL连接; sqlConnection.Close(); MessageBox.Show("添加" + i.ToString() + "行。"); btn_save.Enabled = false; btn_Add.Enabled = true; } } } if (btn_update1.Enabled == false) { MemoryStream memoryStream = new MemoryStream(); this.ptb_Photo.Image.Save(memoryStream, ImageFormat.Bmp); byte[] photoBytes = new byte[memoryStream.Length]; memoryStream.Seek(0, SeekOrigin.Begin); memoryStream.Read(photoBytes, 0, photoBytes.Length); using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "UPDATE tb_medicine" + " SET MName=@MName,IsOTC=@IsOTC,Norm=@Norm,MPrice=@MPrice,ValidDate=@ValidDate,SupplyNo=@SupplyNo,StockNo=@StockNo,Instuction=@Instuction,Photo=@Photo" + " WHERE MNo=@MNo;"; sqlCommand.Parameters.AddWithValue("@MName", this.txt_MName.Text.Trim()); sqlCommand.Parameters.AddWithValue("@IsOTC", this.rdb_OTC.Checked); //sqlCommand.Parameters.AddWithValue("@MNum", this.txt_MNum .Text .Trim ()); sqlCommand.Parameters.AddWithValue("@Norm", this.txt_norm.Text.Trim()); sqlCommand.Parameters.AddWithValue("@MPrice", this.txt_MPrice.Text.Trim()); sqlCommand.Parameters.AddWithValue("@ValidDate", this.dtp_ValidDate.Value); sqlCommand.Parameters.AddWithValue("@SupplyNo", this.cob_Supply.SelectedValue); sqlCommand.Parameters.AddWithValue("@StockNo", this.cob_Stock.SelectedValue); sqlCommand.Parameters.AddWithValue("@Instuction", this.txt_Instruction.Text.Trim()); //sqlCommand.Parameters.AddWithValue("@pinyin", this.txt_pinyin.Text.Trim()); sqlCommand.Parameters.AddWithValue("@Photo", photoBytes); sqlCommand.Parameters.AddWithValue("@MNo", this.txt_MNo.Text.Trim()); sqlConnection.Open(); int rowAffected = sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); MessageBox.Show("更新" + rowAffected.ToString() + "行。"); } btn_save.Enabled = false; btn_update1.Enabled = true; } if (btn_Delete.Enabled == false) { if (MessageBox.Show("确认删除编号为" + txt_MNo.Text + "的数据?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "Delete tb_medicine" + " WHERE MNo=@MNo;"; sqlCommand.Parameters.AddWithValue("@MNo", this.txt_MNo.Text.Trim()); sqlConnection.Open(); int rowAffected = sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); MessageBox.Show("删除" + rowAffected.ToString() + "行。"); } txt_Instruction.Clear(); txt_MName.Clear(); txt_MNo.Clear(); //txt_MNum.Clear(); txt_MPrice.Clear(); txt_norm.Clear(); rdb_OTC.Checked = false; rdb_Rx.Checked = false; ptb_Photo.Image = null; //txt_pinyin.Text = "填写名称拼音缩写"; //txt_pinyin.SelectAll(); } btn_save.Enabled = false; btn_Delete.Enabled = true; } } private void trv_Menu_AfterSelect(object sender, TreeViewEventArgs e) { if (this.trv_Menu.SelectedNode == xinxinode_Client) { this.Hide(); frm_Client f = new frm_Client(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Supply) { this.Hide(); frm_Supply f = new frm_Supply(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == xinxinode_Medicine) { this.Hide(); medicine f = new medicine(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_caigou) { this.Hide(); frm_caigou f = new frm_caigou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_jiesuan) { this.Hide(); frm_caigouOrder f = new frm_caigouOrder(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jinhuoNode_ruku) { this.Hide(); frm_caigouStored f = new frm_caigouStored(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == chuhuoNode_yuji) { this.Hide(); frm_chushou f = new frm_chushou(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == qijianNode_caigou) { this.Hide(); frm_Analysis_qijian f = new frm_Analysis_qijian(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == jiduNode_caigou) { this.Hide(); frm_Analysis f = new frm_Analysis(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_youxiaoqi) { this.Hide(); frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kukunNode_kucun) { this.Hide(); frm_seek f = new frm_seek(); f.ShowDialog(this); } else if (this.trv_Menu.SelectedNode == kucunNode_yaoku) { this.Hide(); frm_Stock f = new frm_Stock(); f.ShowDialog(this); } } private void person_Click(object sender, EventArgs e) { this.Hide(); personnel p = new personnel(); p.ShowDialog(this); } private void 退出登录ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("确认退出本系统?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Application.Exit(); } } private void lianxiToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("致电谢雪妮:15060120822"); } private void 修改密码_Click(object sender, EventArgs e) { this.Hide(); frm_FindPwd f = new frm_FindPwd(); f.ShowDialog(this); } } }
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; using System.Data.SqlClient; using System.Configuration; using System.Drawing.Printing; namespace 药品信息管理系统 { public partial class personnel : Form { public personnel() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; //this.dgv_SupplyTable.AllowUserToAddRows = true ; this.dgv_Medicine.RowHeadersVisible = false; this.dgv_Medicine.AllowUserToAddRows = false; this.dgv_Medicine.AllowUserToDeleteRows = false; this.dgv_Medicine.ReadOnly = true; this.dgv_Medicine.BackgroundColor = Color.White; this.dgv_Medicine.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Medicine.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv_Medicine.ColumnHeadersHeight = 30; dgv_Medicine.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Medicine.ColumnHeadersDefaultCellStyle.Font = new Font("微软雅黑", 10, FontStyle.Bold); dgv_Medicine.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Medicine.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Medicine.ColumnHeadersDefaultCellStyle.ForeColor = ColorTranslator.FromHtml("#fff"); dgv_Medicine.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgv_Medicine.GridColor = ColorTranslator.FromHtml("#006CB3"); dgv_Medicine.BackgroundColor = ColorTranslator.FromHtml("#E7F5FF"); dgv_Medicine.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dgv_Medicine.RowHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#0099FF"); dgv_Medicine.RowTemplate.Height = 30; dgv_Medicine.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgv_Medicine.DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#97D5FF"); dgv_Medicine.AlternatingRowsDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#E1F3FF"); } private void personnel_Load(object sender, EventArgs e) { lb_ID.Text =frm_LogIn.AdminNo.ToString(); lb_M.Text = "真实姓名:" + frm_LogIn.AdminName.ToString() + " " + "联系电话:" + frm_LogIn.tel .ToString(); } private void button1_Click(object sender, EventArgs e) { if(cob_seek .Text =="") { MessageBox.Show("请先选择查询条件"); } else if (cob_seek.Text == "历史采购记录") { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "select s.caigouDate,t.AName,m.MName,m.Norm,s.num,m.MPrice,s.Price,s.isPaid ,s.SupplyNo from tb_SelectMedicineBySupply as s join tb_medicine as m on m.MNo =s.MNo join tb_Supply as ss on ss.SupplyNo=s.SupplyNo join tb_Admin as t on t.ANo=s.ANo where s.ANO= '" + frm_LogIn .AdminNo .ToString () + "'and isPaid=0"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; //DataTable ClientTable = new DataTable(); DataTable caigouOrderTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(caigouOrderTable); sqlConnection.Close(); this.dgv_Medicine.Columns.Clear(); this.dgv_Medicine.DataSource = caigouOrderTable; this.dgv_Medicine.Columns["caigouDate"].HeaderText = "日期"; //this.dgv_Medicine.Columns["caigouNo"].HeaderText = "流水号"; this.dgv_Medicine.Columns["Norm"].HeaderText = "药品规格"; this.dgv_Medicine.Columns["MName"].HeaderText = "药品名称"; this.dgv_Medicine.Columns["num"].HeaderText = "药品数量"; this.dgv_Medicine.Columns["MPrice"].HeaderText = "药品单价"; //this.dgv_Medicine.Columns["MNo"].HeaderText = "药品编号"; //this.dgv_Client.Columns["pinyin"].Visible = false; this.dgv_Medicine.Columns["Price"].HeaderText = "药品总价"; this.dgv_Medicine.Columns["isPaid"].Visible = false; this.dgv_Medicine.Columns["AName"].HeaderText = "采购员"; this.dgv_Medicine.Columns["SupplyNo"].Visible = false; //this.dgv_Medicine.Columns["CName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } else if (cob_seek.Text == "历史结算记录") { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "select s.PaidDate,s.PaidAdmin,m.MNo,m.MName,m.Norm,s.num,s.isPaid ,s.isStored from tb_SelectMedicineBySupply as s join tb_medicine as m on m.MNo =s.MNo join tb_Supply as ss on ss.SupplyNo=s.SupplyNo join tb_Admin as t on t.ANo=s.ANo where PaidAdmin ='" + frm_LogIn .AdminName .ToString () + "' and isPaid=1 and isStored=0"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; //DataTable ClientTable = new DataTable(); DataTable StoredTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(StoredTable); sqlConnection.Close(); this.dgv_Medicine.Columns.Clear(); this.dgv_Medicine.DataSource = StoredTable; //this.dgv_Medicine.Columns["caigouDate"].HeaderText = "采购日期"; // this.dgv_Medicine.Columns["caigouDate"].ReadOnly = true; //his.dgv_Medicine.Columns["caigouNo"].HeaderText = "流水号"; this.dgv_Medicine.Columns["Norm"].HeaderText = "药品规格"; this.dgv_Medicine.Columns["MName"].HeaderText = "药品名称"; this.dgv_Medicine.Columns["num"].HeaderText = "药品数量"; this.dgv_Medicine.Columns["PaidAdmin"].HeaderText = "结算员"; this.dgv_Medicine.Columns["MNo"].HeaderText = "药品编号"; //this.dgv_Client.Columns["pinyin"].Visible = false; this.dgv_Medicine.Columns["PaidDate"].HeaderText = "结算日期"; this.dgv_Medicine.Columns["isPaid"].HeaderText = "付款状态"; //this.dgv_Medicine.Columns["AName"].HeaderText = "采购员"; //this.dgv_Medicine.Columns["isStored"].HeaderText = "入库状态"; this.dgv_Medicine.Columns["isStored"].Visible = false; //dgv_Medicine.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //this.dgv_Medicine.Columns["CName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } else if (cob_seek.Text == "历史入库记录") { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "select StoreAdmin,m.MNo,m.MName,m.Norm,s.num,s.isStored from tb_SelectMedicineBySupply as s join tb_medicine as m on m.MNo =s.MNo join tb_Supply as ss on ss.SupplyNo=s.SupplyNo join tb_Admin as t on t.ANo=s.ANo where StoreAdmin ='" + frm_LogIn.AdminName.ToString() + "' and isStored=1"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; //DataTable ClientTable = new DataTable(); DataTable StoredTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(StoredTable); sqlConnection.Close(); this.dgv_Medicine.Columns.Clear(); this.dgv_Medicine.DataSource = StoredTable; //this.dgv_Medicine.Columns["caigouDate"].HeaderText = "采购日期"; // this.dgv_Medicine.Columns["caigouDate"].ReadOnly = true; //his.dgv_Medicine.Columns["caigouNo"].HeaderText = "流水号"; this.dgv_Medicine.Columns["Norm"].HeaderText = "药品规格"; this.dgv_Medicine.Columns["MName"].HeaderText = "药品名称"; this.dgv_Medicine.Columns["num"].HeaderText = "药品数量"; this.dgv_Medicine.Columns["StoreAdmin"].HeaderText = "入库员"; this.dgv_Medicine.Columns["MNo"].HeaderText = "药品编号"; //this.dgv_Client.Columns["pinyin"].Visible = false; //this.dgv_Medicine.Columns["PaidDate"].HeaderText = "结算日期"; //this.dgv_Medicine.Columns["isPaid"].HeaderText = "付款状态"; //this.dgv_Medicine.Columns["AName"].HeaderText = "采购员"; this.dgv_Medicine.Columns["isStored"].HeaderText = "入库状态"; this.dgv_Medicine.Columns["isStored"].Visible = false; //dgv_Medicine.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //this.dgv_Medicine.Columns["CName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } else if (cob_seek.Text == "历史出售记录") { using (SqlConnection sqlConnection = new SqlConnection(DBHelper.connString)) { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "select chushouDate,t.AName,cc.CName,m.MName,Num,price from tb_chushou as c join tb_medicine as m on m.MNo =c.MNo join tb_Client as cc on cc.CNO=c.CNO join tb_Admin as t on t.ANo=c.ANO where t.AName ='" + frm_LogIn.AdminName.ToString() +"'"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; //DataTable ClientTable = new DataTable(); DataTable StoredTable = new DataTable(); sqlConnection.Open(); sqlDataAdapter.Fill(StoredTable); sqlConnection.Close(); this.dgv_Medicine.Columns.Clear(); this.dgv_Medicine.DataSource = StoredTable; this.dgv_Medicine.Columns["chushouDate"].HeaderText = "出售日期"; this.dgv_Medicine.Columns["AName"].HeaderText = "出售员"; this.dgv_Medicine.Columns["MName"].HeaderText = "药品名称"; this.dgv_Medicine.Columns["Num"].HeaderText = "药品数量"; this.dgv_Medicine.Columns["CName"].HeaderText = "客户"; this.dgv_Medicine.Columns["price"].HeaderText = "价格"; //dgv_Medicine.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //this.dgv_Medicine.Columns["CName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.dgv_Medicine.Columns[this.dgv_Medicine.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } } } }