vs2017 sql server 2008/sql server 2012/sql server 2016
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace SuperMarket{ public partial class MainForm : Form { public MainForm() { InitializeComponent(); } private void Timer() { string year = DateTime.Now.Year.ToString(); string month = DateTime.Now.Month.ToString(); string day = DateTime.Now.Day.ToString(); string weeks = DateTime.Now.DayOfWeek.ToString(); string hour = DateTime.Now.Hour.ToString(); string minute = DateTime.Now.Minute.ToString();//5^1^a^s^p^x string second = DateTime.Now.Second.ToString(); string minutes = (Convert.ToInt32(minute) < 10) ? "0" minute : minute; string week = ""; switch (weeks) { case "Monday": week = "星期一"; break; case "Tuesday": week = "星期二"; break; case "Wednesday": week = "星期三"; break; case "Thursday": week = "星期四"; break; case "Friday": week = "星期五"; break; case "Saturday": week = "星期六"; break; case "Sunday": week = "星期日"; break; } tlbltime.Text = hour "时" minutes "分" second "秒"; this.tlblUserID.Text = " " LoginDB.user " " LoginDB.userStyle " 欢迎操作本系统 "; tlbdate.Text = " 今天是:" year "年" month "月" day "日" " " week " 现在是:"; } //返回子窗体 private Form FindMdiChild(string text)///////////////////////////////////////////// { foreach (Form form in this.MdiChildren) { if (form.Text == text) { return form; } } return null; } //如果窗体打开则不再打开 private bool ActivateMdi(string text)///////////////////////////////////////////// { Form f = FindMdiChild(text); if (f != null) { f.Activate(); return true; } return false; } private void OpenFormSelectIndex(int page)////////////////////////////////////// { foreach (Form f in this.MdiChildren) { if (f.Text.Equals("商品管理")) { f.Close(); } } MarchMag marchMag = new MarchMag(page); marchMag.MdiParent = this; marchMag.Show(); } private void QryStaticMemberIndex(int page)/////////////////////////////////////// { foreach (Form f in this.MdiChildren) { if (f.Text.Equals("会员管理员")) { f.Close(); } } QryStaticMember qryStaticMember = new QryStaticMember(page); qryStaticMember.MdiParent = this; qryStaticMember.Show(); } /************************************************************************/ private void timer1_Tick(object sender, EventArgs e) { this.Timer(); } private void t_UserMag_Click(object sender, EventArgs e) { UserMag userMag = new UserMag(); if (!ActivateMdi("用户管理")) { userMag.MdiParent = this; userMag.Show(); } } private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e) { UpdatePwd updatePwd = new UpdatePwd(); if (!ActivateMdi("修改密码")) { updatePwd.MdiParent = this; updatePwd.Show(); } } private void 进货管理ToolStripMenuItem_Click(object sender, EventArgs e) { InputMarch inputmarch = new InputMarch(); if (!ActivateMdi("进货管理")) { inputmarch.MdiParent = this; inputmarch.Show(); } } private void 库存管理ToolStripMenuItem_Click(object sender, EventArgs e) { OpenFormSelectIndex(1); } private void 销售管理ToolStripMenuItem_Click(object sender, EventArgs e) { OpenFormSelectIndex(0); } private void 会员管理ToolStripMenuItem1_Click(object sender, EventArgs e) { QryStaticMemberIndex(1); } private void 会员信息查询和统计ToolStripMenuItem_Click(object sender, EventArgs e) { QryStaticMemberIndex(0); } private void 销售信息录入ToolStripMenuItem_Click(object sender, EventArgs e) { if (!ActivateMdi("销售信息录入")) { InputSale inputSale = new InputSale(); inputSale.MdiParent = this; inputSale.Show(); } } private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) { if (shows.showDialog("欢迎使用本系统!您确定退出本系统吗?")) { this.Close(); Application.Exit(); } } private void MainForms_Load(object sender, EventArgs e) { string userStyle = LoginDB.userStyle; if (userStyle == "销售人员") { 销售信息录入ToolStripMenuItem.Enabled = true; 修改密码ToolStripMenuItem.Enabled = true; 销售信息录入ToolStripMenuItem1.Enabled = true; btnSaleInput.Visible = true; } else if (userStyle == "经理") { 用户管理ToolStripMenuItem.Enabled = true; 进货管理ToolStripMenuItem.Enabled = true; 库存管理ToolStripMenuItem.Enabled = true; 销售管理ToolStripMenuItem.Enabled = true; 会员信息查询和统计ToolStripMenuItem.Enabled = true; 会员管理ToolStripMenuItem1.Enabled = true; 销售信息录入ToolStripMenuItem.Enabled = true; 修改密码ToolStripMenuItem.Enabled = true; /*************************************************/ btnuserMag.Visible = true; btnUpdatePwd.Visible = true; btnInputMerch.Visible = true; btnStockMag.Visible = true; btnMerchMag.Visible = true; btnMemberMag.Visible = true; btnMemberSearch.Visible = true; btnSaleInput.Visible = true; /*************************************************/ 用户管理ToolStripMenuItem1.Enabled = true; 进货管理ToolStripMenuItem1.Enabled = true; 库存管理ToolStripMenuItem1.Enabled = true; 会员信息查寻和统计ToolStripMenuItem.Enabled = true; 会员管理ToolStripMenuItem2.Enabled = true; 销售信息录入ToolStripMenuItem1.Enabled = true; 商品管理ToolStripMenuItem1.Enabled = true; } this.Timer(); } private void 重新登录ToolStripMenuItem_Click(object sender, EventArgs e) { LoginDB Login = new LoginDB(); Context.context.MainForm = Login; Login.Show(); this.Close(); } private void 关于ToolStripMenuItem_Click(object sender, EventArgs e) { About about = new About(); if (!ActivateMdi("关于")) { about.MdiParent = this; about.Show(); } } }}
评论