Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != "")
     {
         var sql   = $"SELECT TOP 1 * FROM udbz WHERE name='{textBox1.Text.Trim().ToUpper()}'";
         var sdra5 = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql);
         if (sdra5.HasRows)
         {
             sdra5.Close();
             MessageBox.Show($"此工序名称【{textBox1.Text.Trim()}】已存在,请重新输入!!", "提示");
             textBox1.Text = "";
             textBox1.Focus();
             Goiss();
         }
         else
         {
             sdra5.Close();
             var sqltk = $"insert into udbz(name) values('{textBox1.Text.Trim().ToUpper()}')";
             SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sqltk);
             textBox1.Text = "";
             textBox1.Focus();
         }
     }
     else
     {
         MessageBox.Show("工序名称不能为空", "提示");
         textBox1.Focus();
     }
 }
Ejemplo n.º 2
0
 private void button5_Click(object sender, EventArgs e)//新建保存
 {
     if (textBox2.Text != "")
     {
         if (textBox4.Text != "")
         {
             if (comboBox1.Text != "")
             {
                 if (SqlHelper.UserName == "管理" && comboBox1.Text.Trim() == Resources.UT_Admin)
                 {
                     MessageBox.Show("此帐号不可以创建<admin>帐号,请重新输入!!", Resources.T提示);
                 }
                 else
                 {
                     var sql     = $"SELECT ID FROM IDPASS WHERE ID='{textBox2.Text.Trim()}'";
                     var sdddr1Q = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql);
                     if (sdddr1Q.HasRows)
                     {
                         MessageBox.Show($"此帐号< {textBox2.Text.Trim()} >已存在,请重新输入!!", Resources.T提示);
                         textBox2.Text = "";
                         sdddr1Q.Close();
                     }
                     else
                     {
                         sdddr1Q.Close();
                         sql =
                             $"insert into IDPASS(ID,pass,name,leiq) values('{textBox2.Text.Trim()}','{textBox3.Text.Trim()}','{textBox4.Text.Trim()}','{comboBox1.Text.Trim()}')";
                         SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql);
                         textBox2.Text  = "";
                         textBox3.Text  = "";
                         textBox4.Text  = "";
                         comboBox1.Text = "";
                         GetUserInfo();
                     }
                 }
             }
             else
             {
                 MessageBox.Show("帐号类型不能为空!", Resources.T提示);
             }
         }
         else
         {
             MessageBox.Show("姓名不能为空!", Resources.T提示);
             textBox4.Focus();
         }
     }
     else
     {
         MessageBox.Show("帐号不能为空!", Resources.T提示);
         textBox2.Focus();
     }
 }
Ejemplo n.º 3
0
 private void btnLogon_Click(object sender, EventArgs e)
 {
     if (txtUserId.Text == "")
     {
         MessageBox.Show(@"请输入登录帐号!!", Resources.T提示);
         txtUserId.Focus();
     }
     else
     {
         var sql = $"SELECT TOP 1 * FROM IDPASS WHERE ID='{txtUserId.Text.Trim()}'";
         try
         {
             var dr = SqlHelper.ExecuteReader(SqlHelper.GetConnSting(), CommandType.Text, sql);
             if (dr.Read())
             {
                 var pass = dr["pass"].ToString().Trim();
                 if (txtPassword.Text.Trim() == pass)
                 {
                     SqlHelper.UserName = dr["name"].ToString().Trim();
                     SqlHelper.UserType = dr["leiq"].ToString().Trim();
                     SqlHelper.DeptId   = dr["DeptId"].ToString().Trim();
                     SqlHelper.UserId   = txtUserId.Text.Trim();
                     Hide();
                     BLogin       = true;
                     DialogResult = DialogResult.OK;
                 }
                 else
                 {
                     MessageBox.Show(@"密码错误,请重新输入!", Resources.T提示);
                     txtPassword.Text = "";
                     txtPassword.Focus();
                 }
             }
             else
             {
                 MessageBox.Show($"此帐号< {txtUserId.Text.Trim()} >不存在,请重新输入!!", Resources.T提示);
                 txtUserId.Text   = "";
                 txtPassword.Text = "";
                 txtUserId.Focus();
             }
             dr.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(@"数据库连接错误!" + ex.Message);
         }
     }
 }
Ejemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)//修改
        {
            _mMid = dataGridView1.SelectedCells[0].Value.ToString().Trim();
            //MMid = Convert.ToInt32(dataGridView1.SelectedCells[0].Value);
            panel2.Visible = true;
            var sql = $"SELECT * FROM IDPASS WHERE lu='{_mMid}'";
            var sdr = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql);

            sdr.Read();
            textBox8.Text  = sdr["lu"].ToString().Trim();
            textBox7.Text  = sdr["ID"].ToString().Trim();
            textBox6.Text  = sdr["pass"].ToString().Trim();
            textBox5.Text  = sdr["name"].ToString().Trim();
            comboBox2.Text = sdr["leiq"].ToString().Trim();
            sdr.Close();
        }
Ejemplo n.º 5
0
        private void btnUpd_Click(object sender, EventArgs e)
        {
            if (btnUpd.Text == Resources.X修改)
            {
                if (MessageBox.Show("是否已经选择好所要修改的行,若未选好请按取消!", Resources.T提示, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    var employeeId = dataGridView2.SelectedCells[0].Value.ToString().Trim();

                    var sql = $"SELECT a.ID,b.Team '班组名称',a.Name '员工' FROM PD_ProcCard_Employee a JOIN dbo.PD_ProcCard_Team b ON b.ID=a.TeamId WHERE a.ID='{employeeId}'";
                    var dr  = SqlHelper.ExecuteReader(SqlHelper.GetConnectionString("dzdj"), CommandType.Text, sql);
                    if (dr.HasRows)
                    {
                        dr.Read();
                        comboBox1.Text = dr[1].ToString().Trim();
                        textBox2.Text  = dr[2].ToString().Trim();
                        comboBox1.Tag  = dr[0].ToString().Trim();
                        dr.Close();
                        btnAdd.Visible = false;
                        btnDel.Visible = false;
                        btnUpd.Text    = Resources.X保存;
                    }
                    else
                    {
                        dr.Close();
                    }
                }
            }
            else
            {
                var sql =
                    $"UPDATE PD_ProcCard_Employee SET TeamId='{comboBox1.SelectedValue}',Name='{textBox2.Text.Trim().ToUpper()}'WHERE id ={Convert.ToInt32(comboBox1.Tag)}";
                SqlHelper.ExecuteNonQuery(SqlHelper.GetConnectionString("dzdj"), CommandType.Text, sql);
                btnUpd.Text    = Resources.X修改;
                btnAdd.Visible = true;
                btnDel.Visible = true;
                textBox2.Text  = "";
                comboBox1.Text = "";
                InitData();
            }
        }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            var sql   = $"SELECT TOP 1 * FROM IDPASS WHERE ID='{textBox1.Text.Trim()}'";
            var s5Dr5 = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql);

            if (s5Dr5.HasRows)
            {
                s5Dr5.Read();
                var adss = s5Dr5["pass"].ToString().Trim();
                if (textBox2.Text.Trim() == adss)
                {
                    if (textBox3.Text.Trim() == textBox4.Text.Trim())
                    {
                        sql = "";
                        sql = $"UPDATE IDPASS set pass='******' WHERE ID='{textBox1.Text.Trim()}'";
                        SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql);
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("新密码输入不一致,请重新输入!", "提示");
                        textBox3.Text = "";
                        textBox4.Text = "";
                        textBox3.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("当前密码与登录的密码不一致,请重新输入!", "提示");
                    textBox2.Text = "";
                    textBox3.Text = "";
                    textBox4.Text = "";
                    textBox2.Focus();
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     使用参数化登录
        /// </summary>
        /// <param name="args"></param>
        private static void LoginByArgs(string[] args)
        {
            var commandArgs = CommandLine.Parse(args);

            if (commandArgs.ArgPairs.Count <= 0)
            {
                return;
            }

            #region 获取用户参数

            var userName     = string.Empty;
            var userPassword = string.Empty;
            foreach (var pair in commandArgs.ArgPairs)
            {
                if ("U".Equals(pair.Key, StringComparison.OrdinalIgnoreCase))
                {
                    userName = pair.Value;
                }
                if ("P".Equals(pair.Key, StringComparison.OrdinalIgnoreCase))
                {
                    userPassword = pair.Value;
                }
            }

            #endregion

            //if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(identity))
            //{
            //    bool bLogin = Portal.gc.LoginByIdentity(userName.Trim(), identity);
            //    if (bLogin)
            //    {
            //        ShowMainDialog();
            //    }
            //    else
            //    {
            //        LoginNormal(args);
            //    }
            //}
            //string userName = commandArgs.ArgPairs["U"];
            //string userPassword = commandArgs.ArgPairs.ContainsKey("P") ? commandArgs.ArgPairs["P"] : "";
            if (!string.IsNullOrEmpty(userName))
            {
                //var localIp = NetworkUtil.GetLocalIP();
                //if (localIp == null) throw new ArgumentNullException("args");
                //var macAddress = HardwareInfoHelper.GetMacAddress();
                //if (macAddress == null) throw new ArgumentNullException("args");
                //if (
                //    !string.IsNullOrEmpty(BLLFactory<User>.Instance.VerifyUser(userName, userPassword, Gc.AppWholeName,
                //        localIp, macAddress)))
                //{
                //    var userByName = BLLFactory<User>.Instance.GetUserByName(userName);
                //    var functionsByUser = BLLFactory<Function>.Instance.GetFunctionsByUser(userByName.ID,
                //        Gc.AppWholeName);
                //    if ((functionsByUser != null) && (functionsByUser.Count > 0))
                //    {
                //        foreach (
                //            var functionInfo in
                //                functionsByUser.Where(
                //                    functionInfo => !Gc.FunctionDict.ContainsKey(functionInfo.ControlID)))
                //        {
                //            Gc.FunctionDict.Add(functionInfo.ControlID, functionInfo.ControlID);
                //        }
                //    }
                //    Gc.UserInfo = userByName;
                //    Gc.LoginUserInfo = Gc.ConvertToLoginUser(userByName);
                //    Cache.Instance.Add("LoginUserInfo", Gc.LoginUserInfo);
                //    Cache.Instance.Add("FunctionDict", Gc.FunctionDict);
                //    //gc.ManagedWareHouse = gc.GetWareHouse(userByName);
                //    //if ((gc.ManagedWareHouse != null) && (gc.ManagedWareHouse.Count > 0))
                //    //{
                //    Splasher.Show(typeof(FrmSplash));
                //    Gc.MainDialog = new MainForm { StartPosition = FormStartPosition.CenterScreen };
                //    Application.Run(Gc.MainDialog);
                //    //}
                //    //else
                //    //{
                //    //    MessageUtil.ShowTips("用户登录信息正确,但未授权管理库房信息,请联系管理人员授权管理");
                //    //    GetAllURL(string_0);
                //    //}
                //else
                //{
                //    MessageUtil.ShowTips("用户帐号密码不正确");
                //    LoginNormal();
                //}
                var sql = $"SELECT TOP 1 * FROM IDPASS WHERE ID='{userName}'";
                try
                {
                    var dr = SqlHelper.ExecuteReader(SqlHelper.GetConnSting(), CommandType.Text, sql);
                    if (dr.Read())
                    {
                        var pass = dr["pass"].ToString().Trim();
                        if (userPassword == pass)
                        {
                            SqlHelper.UserName = dr["name"].ToString().Trim();
                            SqlHelper.UserType = dr["leiq"].ToString().Trim();
                            SqlHelper.DeptId   = dr["DeptId"].ToString().Trim();
                            SqlHelper.UserId   = userName;

                            Splasher.Show(typeof(FrmSplash));
                            Gc.MainDialog = new MainForm {
                                StartPosition = FormStartPosition.CenterScreen
                            };
                            Application.Run(Gc.MainDialog);
                        }
                        else
                        {
                            MessageBox.Show(@"密码错误,请重新输入!", Resources.T提示);
                            LoginNormal();
                        }
                    }
                    else
                    {
                        MessageBox.Show($"此帐号< {userName} >不存在,请重新输入!!", Resources.T提示);
                    }
                    dr.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(@"数据库连接错误!" + ex.Message);
                }
            }
            else
            {
                MessageUtil.ShowTips("命令格式有误");
                LoginNormal();
            }
        }