public static bool CertifyCDK(string CDK)//验证CDK { //string testCDK = Encrypt(FeatureCode+":150", KEY); try { string middle = Decrypt(CDK, KEY);//解密CDK string[] sArray = Regex.Split(middle, ":", RegexOptions.IgnoreCase); uint day = uint.Parse(sArray[1]); if (sArray[0] == FeatureCode)//验证成功 { MessageBox.Show("激活成功!欢迎使用!"); DataService.UpdataPer(FeatureCode, day);//更新授权表数据 if (ControCenter.FirstUse == true) { employeeInfo emp = new employeeInfo(); emp.Name = "1"; emp.Password = "******"; emp.Type = "管理员"; MessageBox.Show("初始用户名:1,密码:1 登陆后请自行修改密码"); DataService.AddEmployee(emp); } return(true); } else { return(false); } } catch { return(false); } }
private void button6_Click(object sender, EventArgs e) { employeeInfo newEmp = new employeeInfo(); newEmp.Name = this.tex_user.Text; newEmp.Password = this.tex_pwd.Text; if (this.checkBox1.Checked == true) { newEmp.Type = "管理员"; } else { newEmp.Type = "员工"; } int ret = DataService.AddEmployee(newEmp); if (ret > 0) { MessageBox.Show("操作成功!"); } else { MessageBox.Show("操作失败!"); } this.dataGridView2.DataSource = PdServices.getallpd(); }
public static List <employeeInfo> getallpd() { string sql = "select * from EmployeeInfo"; OleDbDataReader dr = Dbhelper.ExecuteReader(sql); List <employeeInfo> list = new List <employeeInfo>(); if (dr != null) { while (dr.Read()) { employeeInfo pd = new employeeInfo(); pd.Name = dr[1].ToString(); pd.Id = uint.Parse(dr[0].ToString()); pd.CreateTime = DateTime.Parse(dr[3].ToString()); pd.Type = dr[4].ToString(); if (pd.Id > 9) { list.Add(pd); } } dr.Close(); } return(list); }
public FormUpdate(employeeInfo adminfor) { InitializeComponent(); admin = adminfor; admin.Name = this.tex_user.Text; admin.Password = this.tex_pwd.Text; this.CenterToParent(); }
private void button8_Click(object sender, EventArgs e) { string str = MessageBox.Show("你确定要删除选中项目吗?", "警告", MessageBoxButtons.YesNo).ToString(); if (str == "Yes") { employeeInfo admin = new employeeInfo(); if (this.dataGridView2.SelectedRows.Count > 0) { for (int i = 0; i < dataGridView2.SelectedRows.Count; i++) { DataGridViewRow dr = dataGridView2.SelectedRows[i]; admin.Id = uint.Parse(dr.Cells[0].Value.ToString()); int ret = PdServices.DlePd(admin); if (ret > 0) { } else { //MessageBox.Show(string.Format("第{0}条删除失败!", i + 1)); } } } else { DataGridViewCell dc = this.dataGridView2.SelectedCells[0]; // DataGridViewRow dr = dc.RowNumber; // dc = dr.Cells[0]; DataGridViewRow dr = dc.OwningRow; // MessageBox.Show(dr.Cells[0].Value.ToString()); admin.Id = uint.Parse(dr.Cells[0].Value.ToString()); // MessageBox.Show(pd.Pdid.ToString()); int ret = PdServices.DlePd(admin); if (ret > 0) { MessageBox.Show("操作成功!"); } else { MessageBox.Show("操作失败!"); } } this.dataGridView2.DataSource = PdServices.getallpd(); } }
//修改 private void btnInfoEdit_Click(object sender, EventArgs e) { if (listInfo.SelectedItems.Count == 0) { return; } ListViewItem item = listInfo.SelectedItems[0]; if (txtInfoName.Text == "" || txtInfoTel.Text == "" || txtInfoIdCard.Text == "") { MessageBox.Show("请输入信息"); return; } DateTime birth = new DateTime(int.Parse(nudInfoYear.Value.ToString()), int.Parse(nudInfoMonth.Value.ToString()), int.Parse(nudInfoDay.Value.ToString())); int sex; if (rbtnInfoMale.Checked == true) { sex = 1; } else { sex = 0; } employeeInfo employee = new employeeInfo() { employeeName = txtInfoName.Text, employeePhone = txtInfoTel.Text, employeeIdentity = txtInfoIdCard.Text, employeeBir = birth, employeeSex = sex, }; int id = int.Parse(item.Text); if (dataTools.updateTools.updateEmployeeInfo(x => x.employeeId == id, employee) == false) { MessageBox.Show("修改失败"); } else { MessageBox.Show("修改成功"); item.SubItems[1].Text = txtInfoName.Text; item.SubItems[2].Text = Tools.ReturnSex(sex); item.SubItems[3].Text = txtInfoTel.Text; item.SubItems[4].Text = birth.ToString("D"); item.SubItems[5].Text = txtInfoIdCard.Text; } }
/*public void SellCommodity(Commodity type, uint CommodityNum) * { * //在这里获取会员Id * Viper vip = new Viper(123); * float CollectMoney = type.CountMoney(CommodityNum); * //data.SellCommodity(adminId,CommodityType,CommodityNum,CommodityType.pri.type,CollectMoney) * //data.CollectMoney(CollectMoney) * NowLogAdmin.SellCommodity(vip,type, CommodityNum); * }*/ public static bool LogIn(string LogName, string LogPassword) { employeeInfo employee = DataService.LoginEmployee(LogName, LogPassword); if (employee.Name != null) { NowLogName = employee.Name.ToString(); NowLogType = employee.Type.ToString(); return(true); } else { return(false); } }
/// <summary> /// 往职工信息表中插入数据 /// </summary> /// <param name="info"></param> /// <returns>插入数据后的对象</returns> public static bool insertEmployeeInfo(employeeInfo info) { try { using (employeeInfoSystemEntities db = new employeeInfoSystemEntities()) { db.employeeInfo.Add(info); db.SaveChanges(); return(true); } } catch { return(false); } }
/// <summary> /// 查找职工信息 /// </summary> /// <typeparam name="TKey"></typeparam> /// <param name="whereLambda"></param> /// <param name="orderBy"></param> /// <returns></returns> public static employeeInfo[] selectEmployeeInfo <TKey>(Expression <Func <employeeInfo, bool> > whereLambda, Expression <Func <employeeInfo, TKey> > orderBy) { try { using (employeeInfoSystemEntities db = new employeeInfoSystemEntities()) { DbQuery <employeeInfo> dataObject = db.employeeInfo.Where(whereLambda).OrderBy(orderBy) as DbQuery <employeeInfo>; employeeInfo[] infoList = dataObject.ToArray(); return(infoList); } } catch { employeeInfo[] nullInfo = new employeeInfo[0]; return(nullInfo); } }
/// <summary> /// 加载公司就职信息选中项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPerLoad_Click(object sender, EventArgs e) { try { if (Performance.SelectedItems.Count == 0) { return; } ListViewItem item = Performance.SelectedItems[0]; nudPerId.Value = Convert.ToInt32(item.SubItems[0].Text); //根据职工ID找到职工姓名 employeeInfo employee = dataTools.selectTools.selectEmployeeInfo(u => u.employeeId == nudPerId.Value, u => u.employeeId)[0]; nudPerPosId.Value = Convert.ToInt32(item.SubItems[2].Text); nudPerPerformance.Value = decimal.Parse(item.SubItems[4].Text); } catch { MessageBox.Show("出错了!"); return; } }
/// <summary> /// 修改employeeInfo表的数据 /// </summary> /// <param name="whereLambda"></param> /// <param name="info"></param> /// <returns></returns> public static bool updateEmployeeInfo(Expression <Func <employeeInfo, bool> > whereLambda, employeeInfo info) { try { using (employeeInfoSystemEntities db = new employeeInfoSystemEntities()) { DbQuery <employeeInfo> dataObject = db.employeeInfo.Where(whereLambda) as DbQuery <employeeInfo>; employeeInfo oldInfo = dataObject.FirstOrDefault(); oldInfo.employeeName = info.employeeName; oldInfo.employeeSex = info.employeeSex; oldInfo.employeePhone = info.employeePhone; oldInfo.employeeBir = info.employeeBir; oldInfo.employeeIdentity = info.employeeIdentity; db.SaveChanges(); return(true); } } catch { return(false); } }
//添加 private void btnInfoAdd_Click(object sender, EventArgs e) { if (txtInfoName.Text == "" || txtInfoTel.Text == "" || txtInfoIdCard.Text == "") { MessageBox.Show("请输入信息"); return; } DateTime birth = new DateTime(int.Parse(nudInfoYear.Value.ToString()), int.Parse(nudInfoMonth.Value.ToString()), int.Parse(nudInfoDay.Value.ToString())); int sex; if (rbtnInfoMale.Checked == true) { sex = 1; } else { sex = 0; } employeeInfo employee = new employeeInfo() { employeeName = txtInfoName.Text, employeePhone = txtInfoTel.Text, employeeIdentity = txtInfoIdCard.Text, employeeBir = birth, employeeSex = sex, }; if (dataTools.insertTools.insertEmployeeInfo(employee) == false) { MessageBox.Show("添加失败"); } else { MessageBox.Show("添加成功"); } }
private void log() { employeeInfo employee = DataService.LoginEmployee(this.tex_User.Text, this.tex_pwd.Text); //MessageBox.Show(admin.Adminname); try { if (employee.Name != null) { Form_main f = new Form_main(); f.Show(); this.Visible = false; } else { MessageBox.Show("用户名密码错误!!"); this.tex_pwd.Text = ""; } } catch { MessageBox.Show("系统发生不明错误,请联系管理员!!"); } }
public static int DlePd(employeeInfo pd) { string sql = string.Format("delete * from EmployeeInfo where Id={0}", pd.Id); return(Dbhelper.ExecuteNonQuery(sql)); }
public static int UpdatePd(employeeInfo pd) { string sql = string.Format("update EmployeeInfo set EmployeeName='{0}' where Id={1}", pd.Name, pd.Id); return(Dbhelper.ExecuteNonQuery(sql)); }
public FormUpdate() { admin = new employeeInfo(); InitializeComponent(); }