Beispiel #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();
     }
 }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (btnAdd.Text == Resources.A新增)
     {
         btnUpd.Visible = false;
         btnDel.Visible = false;
         btnAdd.Text    = Resources.A保存;
     }
     else
     {
         if (textBox2.Text != "" && comboBox1.Text != "")
         {
             var sql =
                 $"INSERT INTO PD_ProcCard_Employee(TeamId,Name) VALUES({comboBox1.SelectedValue},'{textBox2.Text.Trim().ToUpper()}')";
             SqlHelper.ExecuteNonQuery(SqlHelper.GetConnectionString("dzdj"), CommandType.Text, sql);
             btnUpd.Visible = true;
             btnDel.Visible = true;
             btnAdd.Text    = Resources.A新增;
             textBox2.Text  = "";
             comboBox1.Text = "";
             InitData();
         }
         else
         {
             MessageBox.Show("班组与员工都不可为空!", Resources.T提示);
         }
     }
 }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            var kMMi = dataGridView1.SelectedCells[0].Value.ToString().Trim();

            if (MessageBox.Show("是否要删除所选择的行", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                var sql = $"delete FROM udodt WHERE IDO='{kMMi}'";
                SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql);
                Goiss();
            }
        }
        private void btnDel_Click(object sender, EventArgs e)
        {
            var id = dataGridView2.SelectedCells[0].Value.ToString().Trim();

            if (MessageBox.Show("是否要删除所选择的行", Resources.J警告, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                var sql = $"DELETE FROM PD_ProcCard_Employee WHERE ID='{id}'";
                SqlHelper.ExecuteNonQuery(SqlHelper.GetConnectionString("dzdj"), CommandType.Text, sql);
                InitData();
            }
        }
Beispiel #5
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();
     }
 }
        private void button3_Click(object sender, EventArgs e)//导入数据库
        {
            var strSql = "";

            if (dgvExcelView.RowCount == 0)
            {
                return;
            }
            ;
            var iUpdateCount = 0;

            using (var conn = SqlHelper.GetConnection())
            {
                conn.Open();

                using (var st = conn.BeginTransaction())
                {
                    try
                    {
                        for (var i = 0; i < dgvExcelView.RowCount - 1; i++)
                        {
                            var strId1 = dgvExcelView.Rows[i].Cells["工单号"].Value.ToString();
                            var strId2 = dgvExcelView.Rows[i].Cells["工序号"].Value.ToString();
                            var strId3 = decimal.Parse(dgvExcelView.Rows[i].Cells["序价"].Value + "");
                            var strId4 = decimal.Parse(dgvExcelView.Rows[i].Cells["件资合计"].Value + "");
                            //string strId4 = dgvExcelView.Rows[i].Cells["件资合计"].Value.ToString();
                            //string strId5 = dgvExcelView.Rows[i].Cells["id5"].Value.ToString();
                            if (strId1 == "" || strId2 == "")
                            {
                                continue;
                            }
                            strSql =
                                $"UPDATE tf_sgdantwo set xujia={strId3},hezhi='{strId4}' WHERE shigongdanhao='{strId1}' AND xuhao='{strId2}'";
                            iUpdateCount += SqlHelper.ExecuteNonQuery(st, CommandType.Text, strSql);
                        }
                        st.Commit();
                        MessageBox.Show($"更新成功{iUpdateCount}条记录");
                    }
                    catch (Exception ex)
                    {
                        st.Rollback();
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Beispiel #7
0
 private void button8_Click(object sender, EventArgs e)//修改保存
 {
     if (textBox7.Text != "")
     {
         if (textBox6.Text != "")
         {
             if (textBox5.Text != "")
             {
                 if (comboBox2.Text != "")
                 {
                     if (SqlHelper.UserName == "管理" && comboBox1.Text.Trim() == Resources.UT_Admin)
                     {
                         MessageBox.Show("此帐号不可以修改成<admin>帐号,请重新输入!!", Resources.T提示);
                     }
                     else
                     {
                         var sql =
                             $"UPDATE IDPASS set ID='{textBox7.Text.Trim()}',pass='******',name='{textBox5.Text.Trim()}',leiq='{comboBox2.Text.Trim()}' WHERE lu='{_mMid}'";
                         SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql);
                         GetUserInfo();
                     }
                 }
                 else
                 {
                     MessageBox.Show("帐号类型不能为空!", Resources.T提示);
                 }
             }
             else
             {
                 MessageBox.Show("姓名不能为空!", Resources.T提示);
                 textBox5.Focus();
             }
         }
         else
         {
             MessageBox.Show("密码不能为空!", Resources.T提示);
             textBox6.Focus();
         }
     }
     else
     {
         MessageBox.Show("帐号不能为空!", Resources.T提示);
         textBox7.Focus();
     }
 }
Beispiel #8
0
 private void button3_Click(object sender, EventArgs e)//删除
 {
     if (dataGridView1.SelectedRows.Count == 0)
     {
         MessageBox.Show("提示:请选择要删除的用户信息!", Resources.J警告);
     }
     else
     {
         var mMid = dataGridView1.SelectedCells[0].Value.ToString().Trim();
         if (MessageBox.Show($"是否要删除< {mMid} >序号用户", Resources.J警告, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
         {
             var sql = $"delete FROM IDPASS WHERE lu='{mMid}'";
             SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql);
             GetUserInfo();
         }
         else
         {
             GetUserInfo();
         }
     }
 }
        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();
            }
        }
Beispiel #10
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();
                }
            }
        }