/// <summary> /// 记住密码 自动填充效果 加载头像 /// </summary> private void initialData() { if (this.InvokeRequired) { this.BeginInvoke(new LoadDele(initialData)); } else { this.pictureBoxOfHeadIcon.BackgroundImage = WorkLogForm.Properties.Resources.AutoIconBigWhite; if (IniReadAndWrite.IniReadValue("temp", "rem").Equals(CommonStaticParameter.YES)) { string un = Securit.DeDES(IniReadAndWrite.IniReadValue("temp", "un")); string pwd = Securit.DeDES(IniReadAndWrite.IniReadValue("temp", "pw")); string myid = IniReadAndWrite.IniReadValue("temp", "myid"); this.pictureBoxOfRememberPwd.BackgroundImage = WorkLogForm.Properties.Resources.Checked; #region 加载自己的头像 string address = CommonStaticParameter.ICONS + @"\" + myid + ".png"; if (File.Exists(address)) { //string filename = address;//如果不是png类型,须转换 //System.Drawing.Bitmap ybitmap = new System.Drawing.Bitmap(filename); this.pictureBoxOfHeadIcon.BackgroundImage = CommonClass.ReadPictureFromStream.GetFile(address);//ybitmap; } #endregion //rem_checkBox.Checked = true; textBox1.Text = un != null && un != "" ? un : "请输入用户名"; if (pwd != null && pwd != "") { this.textBox2.UseSystemPasswordChar = true; this.textBox2.Font = new Font(new FontFamily("微软雅黑"), 12); this.textBox2.Font = new Font(new FontFamily("宋体"), 12); this.textBox2.Text = pwd; } else { this.textBox2.IsPasswordChar = false; this.textBox2.Font = new Font(new FontFamily("微软雅黑"), 12); this.textBox2.Font = new Font(new FontFamily("宋体"), 12); this.textBox2.Text = "请输入密码"; } } if (IniReadAndWrite.IniReadValue("temp", "auto").Equals(CommonStaticParameter.YES)) { pictureBoxofAutoLogin.BackgroundImage = WorkLogForm.Properties.Resources.Checked; button1_Click(pictureBox1, new EventArgs()); } } // }
static void MainThread() { string ip = IniReadAndWrite.IniReadValue("connect", "ip"); string id = IniReadAndWrite.IniReadValue("connect", "id"); string pwd = IniReadAndWrite.IniReadValue("connect", "pwd"); string db = IniReadAndWrite.IniReadValue("connect", "db"); main mainForm = new main(thePreUpdateDate); mainForm.User = login.User; mainForm.Role = login.Role; mainForm.loginForm = login; SqlDependency.Start("UID=" + WorkLogForm.CommonClass.Securit.DeDES(id) + ";PWD=" + WorkLogForm.CommonClass.Securit.DeDES(pwd) + ";Database=" + WorkLogForm.CommonClass.Securit.DeDES(db) + ";server=" + WorkLogForm.CommonClass.Securit.DeDES(ip)); mainForm.ShowDialog(); //Application.Run(mainForm); if (mainForm.DialogResult == DialogResult.OK) { update = new Thread(new ThreadStart(onlineUpdate)); update.ApartmentState = ApartmentState.STA; update.Start(); } }
/// <summary> /// 窗口加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDuty_Load(object sender, EventArgs e) { if (role.KrOrder == 3) { this.button4.Visible = false; } this.comboBox1.SelectedIndex = 1; this.comboBox3.SelectedIndex = 2; //查询综合办与网络中心的主任 Therole = 0; affairsDept = IniReadAndWrite.IniReadValue("AdministrationSection", "affairs"); netDept = IniReadAndWrite.IniReadValue("AdministrationSection", "net"); string sql = "select u from WkTUser u left join u.UserRole role where role.KrDESC='工作小秘书角色' and role.KrOrder = 2 and (u.Kdid.KdName like '%" + netDept + "%' or u.Kdid.KdName like '%" + affairsDept + "%') "; IList i = baseService.loadEntityList(sql); foreach (WkTUser o in i) { if (o.Kdid.KdName.Trim() == netDept) { if (user.Id == o.Id) { Therole = 2; } } else if (o.Kdid.KdName.Trim() == affairsDept) { if (user.Id == o.Id) { Therole = 1; } } } loadData(); this.dateTimePicker1.Value = DateTime.Now; }
/// <summary> /// 登录函数 其中包括查库操作 /// </summary> private string loginMethod() { try { #region 将用户信息存入临时文件 if (pictureBoxOfRememberPwd.BackgroundImage != null) { IniReadAndWrite.IniWriteValue("temp", "rem", CommonStaticParameter.YES); } else { IniReadAndWrite.IniWriteValue("temp", "rem", CommonStaticParameter.NO); } if (pictureBoxofAutoLogin.BackgroundImage != null) { IniReadAndWrite.IniWriteValue("temp", "auto", CommonStaticParameter.YES); } else { IniReadAndWrite.IniWriteValue("temp", "auto", CommonStaticParameter.NO); } IniReadAndWrite.IniWriteValue("temp", "un", Securit.DES(textBox1.Text.Trim())); IniReadAndWrite.IniWriteValue("temp", "pw", Securit.DES(textBox2.Text.Trim())); #endregion //判断是否加密成功 IList pwd = baseService.ExecuteSQL("select right(sys.fn_VarBinToHexStr(hashbytes('MD5', '" + textBox2.Text.Trim() + "')),32)"); // 数据库属性,跟具体表无关 if (pwd == null || pwd.Count <= 0) { return("登录异常!"); } object[] pwdArray = (object[])pwd[0]; //因为是共用表 选择是工作小秘书相关的角色 IList userList = baseService.loadEntityList("select u from WkTUser u right join u.UserRole role where role.KrDESC='工作小秘书角色' and u.KuLid='" + textBox1.Text.Trim() + "' and u.KuPassWD='" + pwdArray[0] + "'"); if (userList == null || userList.Count <= 0) { return("用户名或密码错误!"); } else if (userList.Count > 1) { return("用户异常,请联系管理员!"); } else { WkTUser u = (WkTUser)userList[0]; foreach (WkTRole r in u.UserRole) { if (r.KrDESC.Trim().Equals("工作小秘书角色")) //是本系统的用户角色 { role = r; } } this.User = (WkTUser)userList[0]; IniReadAndWrite.IniWriteValue("temp", "myid", User.Id.ToString()); return("登录成功!"); } // } } catch { return("未能与服务器建立连接……"); } }
private void button8_Click(object sender, EventArgs e) { IniReadAndWrite.IniWriteValue("temp", "isSelfStarting", CommonStaticParameter.NO); MessageBox.Show("取消开机启动成功!"); }
private void button4_Click(object sender, EventArgs e) { IniReadAndWrite.IniWriteValue("temp", "auto", CommonStaticParameter.NO); MessageBox.Show("取消自动登录成功!"); }
private void listView5_MouseClick(object sender, MouseEventArgs e) { Business b = (Business)listView5.SelectedItems[0].Tag; IList businessEmployee = getEmpByBus(b); listView6.Items.Clear(); foreach (BusinessEmployee be in businessEmployee) { ListViewItem item = new ListViewItem(); item.Text = be.EmployeeId.KuName; item.SubItems.Add(be.EmployeeId.Kdid.KdName.Trim()); switch (be.PassExam) { case (int)BusinessEmployee.ExamState.waiting: item.SubItems.Add("未审核"); break; case (int)BusinessEmployee.ExamState.pass: item.SubItems.Add("已审核"); break; } item.Tag = be; listView6.Items.Add(item); } DateTime st = new DateTime(b.StartTime), et = new DateTime(b.EndTime); textBox6.Text = b.BusinessReason; textBox7.Text = st.ToString("yyyy年 MM月 dd日") + "----" + et.ToString("yyyy年 MM月 dd日"); textBox8.Text = b.BusinessDestination; textBox20.Text = b.Ku_Id.KuName; textBox12.Text = b.BusinessNote; textBox21.Text = b.Boss.KuName; string affairsDept = IniReadAndWrite.IniReadValue("AdministrationSection", "affairs"); string netDept = IniReadAndWrite.IniReadValue("AdministrationSection", "net"); string queryEmp; if (User.Kdid.KdName.Trim() != affairsDept) { queryEmp = "from BusinessEmployee be where be.BusinessId=" + b.Id + "and be.EmployeeId.Kdid=" + User.Kdid.Id + "and be.PassExam=" + (int)BusinessEmployee.ExamState.waiting + " and be.State=" + (int)BusinessEmployee.stateEnum.Normal; } else { queryEmp = "from BusinessEmployee be where be.BusinessId=" + b.Id + "and (be.EmployeeId.Kdid=" + User.Kdid.Id + " or be.EmployeeId.Kdid.KdName like '%院领导%' ) and be.PassExam=" + (int)BusinessEmployee.ExamState.waiting + " and be.State=" + (int)BusinessEmployee.stateEnum.Normal; } EmpInBusDept = baseService.loadEntityList(queryEmp); if (EmpInBusDept == null || EmpInBusDept.Count == 0) { button4.Enabled = false; button5.Enabled = false; button8.Enabled = false; } else { button4.Enabled = true; button5.Enabled = true; button8.Enabled = true; } selectedBusiness = b; }
private void button1_Click(object sender, EventArgs e) { #region 图片并生成新html Regex r = new Regex("<IMG[\\s\\S]*?>"); MatchCollection mc = r.Matches(htmlEditor1.BodyInnerHTML); ///string[] mc = CommonClass.HtmlUtility.GetElementsByTagName(htmlEditor1.BodyInnerHTML, "IMG"); String html = htmlEditor1.BodyInnerHTML; Uri endpoint = new Uri(Securit.DeDES(IniReadAndWrite.IniReadValue("fileManage", "filePath"))); for (int i = 0; i < mc.Count; i++) { if (mc[i].Value.Contains("src=\"http://")) { continue; } using (WebClient myWebClient = new WebClient()) { myWebClient.UploadFileCompleted += new UploadFileCompletedEventHandler(uploadCompleted); String imgHtml = mc[i].Value; string inPath = HtmlUtility.GetTitleContent(imgHtml, "img", "src"); //imgHtml.Substring(startIndex, imgHtml.LastIndexOf("\"") - startIndex); try { String newName = user.Id + "_" + DateTime.Now.Ticks + inPath.Substring(inPath.LastIndexOf(".")); String tempPath = Application.StartupPath.ToString() + "\\temp\\" + newName; File.Copy(inPath, tempPath, true); myWebClient.UploadFileAsync(endpoint, tempPath); String newString2 = imgHtml.Remove(imgHtml.IndexOf("src"), inPath.Length + 6);//.Remove(imgHtml.LastIndexOf('>'))+" src=\"" + Securit.DeDES(IniReadAndWrite.IniReadValue("fileManage", "savePath")) + newName + "\">"; string newString1 = newString2.Remove(newString2.LastIndexOf('>')); string newString = newString1 + " src=\"" + Securit.DeDES(IniReadAndWrite.IniReadValue("fileManage", "savePath")) + @"LogPic\" + newName + "\">"; //html html = html.Replace(mc[i].Value, newString); } catch (Exception exp) { MessageBox.Show(exp.ToString()); return; } } } #endregion StaffLog staffLog = null; if (htmlEditor1.Tag == null) { staffLog = new StaffLog(); } else if (htmlEditor1.Tag != null) { staffLog = (StaffLog)htmlEditor1.Tag; } staffLog.Content = html; staffLog.State = (int)IEntity.stateEnum.Normal; staffLog.WriteTime = DateTime.Now.Ticks; staffLog.TimeStamp = DateTime.Now.Ticks; staffLog.Staff = user; staffLog.SharedStaffs = sharedUser; try { if (staffLog.Id == 0) { object be = baseService.saveEntity(staffLog); staffLog.Id = int.Parse(be.ToString()); } else if (staffLog.Id != 0) { baseService.SaveOrUpdateEntity(staffLog); } #region 向服务中发送数据 try { KjqbService.Service1Client ser = new KjqbService.Service1Client(); if (sharedUser != null && sharedUser.Count > 0) { foreach (WkTUser u in sharedUser) { KjqbService.LogInService ll = new KjqbService.LogInService(); ll.LogId = staffLog.Id; ll.WriteUserId = this.user.Id; ll.ShareUserId = u.Id; ll.TimeStamp = DateTime.Now.Ticks; ser.SaveInLogListInService(ll); } } } catch { } #endregion } catch { MessageBox.Show("保存失败!"); return; } MessageBox.Show("保存成功!"); this.DialogResult = DialogResult.OK; this.Close(); }