Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string pwd         = "";
            var    md5         = MD5.Create();
            var    computeHash = md5.ComputeHash(Encoding.UTF8.GetBytes(PwdTxt.ToString()));

            foreach (var b in computeHash)
            {
                pwd += b.ToString();
            }

            using (var context = new Model())
            {
                var cStaffBaseInformation = context.C_StaffBaseInformation.FirstOrDefault(s => s.Account == AccountTxt.Text);
                if (cStaffBaseInformation != null)
                {
                    if (cStaffBaseInformation.Password == pwd)
                    {
                        FrmDialog.ShowDialog(this, "登陆成功,欢迎使用!", "登陆成功");
                        // MessageBox.Show("登陆成功,欢迎使用!");
                        this.Hide();

                        string strIp = "";
                        foreach (var ipAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
                        {
                            strIp = ipAddress.ToString();
                        }
                        //在登陆过程表中插入数据
                        var cLoginInProcessing = new C_LoginInProcessing()
                        {
                            StaffCode  = cStaffBaseInformation.StaffCode,
                            StaffID    = cStaffBaseInformation.StaffID,
                            StaffName  = cStaffBaseInformation.StaffName,
                            OnlineTime = context.GetServerDate(),
                            //设备id???
                            EquipmentID   = 1,
                            EquipmentName = "车车中心",
                            IP            = strIp,
                            Remarks       = "测试数据"
                        };

                        context.C_LoginInProcessing.Add(cLoginInProcessing);
                        context.SaveChanges();

                        new MainPanel(cLoginInProcessing.StaffID, cLoginInProcessing.StaffCode, cLoginInProcessing.StaffName).Show();
                    }
                    else
                    {
                        FrmDialog.ShowDialog(this, "密码错误,请重试!", "登陆失败");
                        // MessageBox.Show("密码错误,请重试!");
                    }
                }
                else
                {
                    FrmDialog.ShowDialog(this, "该用户不存在!", "登陆失败");
                    // MessageBox.Show("该用户不存在!");
                }
            }
        }
Ejemplo n.º 2
0
        public void LoginUserTurnArchives(C_LoginInProcessing cLoginInProcessing)
        {
            var mapperConfiguration = new MapperConfiguration(cfg => cfg.CreateMap <C_LoginInProcessing, C_LoginInDocument>());
            var mapper           = mapperConfiguration.CreateMapper();
            var cLoginInDocument = mapper.Map <C_LoginInDocument>(cLoginInProcessing);

            using (var context = new Model())
            {
                //此处应该优化成事务操作 保证acid原则
                context.C_LoginInDocument.Add(cLoginInDocument);
                context.SaveChanges();
                context.Entry(cLoginInProcessing).State = EntityState.Deleted;
                // context.C_LoginInProcessing.Remove(cLoginInProcessing);
                context.SaveChanges();
            }
        }