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提示);
         }
     }
 }
        private void FrmConstructionRpt_Load(object sender, EventArgs e)
        {
            var sql =
                "SELECT c.name 字段,p.value 说明 FROM sys.syscolumns c JOIN sys.systypes t ON c.xusertype=t.xusertype JOIN sys.sysobjects o ON c.id=o.id LEFT JOIN sys.extended_properties p ON c.id=p.major_id AND c.colid=p.minor_id WHERE o.name='tf_sgdantwo' AND t.name LIKE '%date%'";
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            comboBox2.DataSource    = ds.Tables[0];
            comboBox2.DisplayMember = "说明";
            comboBox2.ValueMember   = "字段";
            comboBox2.SelectedIndex = comboBox2.Items.Count - 1;
            checkBox1.Checked       = false;
            checkBox2.Checked       = false;
            checkBox3.Checked       = false;
            if (SqlHelper.UserType == Resources.UT_Input || SqlHelper.UserType == Resources.UT_Admin)
            {
                checkBox4.Visible = true;
                checkBox5.Visible = true;
            }
            sql = "SELECT distinct cust FROM dzdj.dbo.customer";
            ds  = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);
            txtCust.SpellSearchSource = GetSpellBoxSource(ds.Tables[0]).ToArray();
            var acsc = new AutoCompleteStringCollection();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                acsc.Add(dr["cust"].ToString());
            }
            txtCust.AutoCompleteCustomSource = acsc;
        }
Exemplo n.º 3
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();
     }
 }
        /// <summary>
        ///     查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch_Click(object sender, EventArgs e)
        {
            CtrlUtil.ClearDgv(dataGridView1);
            var wheres = new List <string>();

            if (!string.IsNullOrEmpty(dtBegin.Text))
            {
                var time1 = Convert.ToDateTime(dtBegin.Value.Date.ToString("yyyy-MM-dd"));
                wheres.Add($" luodanriqi>='{time1}' ");
            }
            if (!string.IsNullOrEmpty(dtEnd.Text))
            {
                var dt = DateTime.Parse(dtEnd.Text).AddDays(1);
                wheres.Add($" luodanriqi<'{dt}' ");
            }
            if (txtWONo.Text.Trim().Length > 0)
            {
                wheres.Add($" shigongdanhao='{txtWONo.Text.Trim()}'");
            }
            if (txtOrderNo.Text.Trim().Length > 0)
            {
                wheres.Add($" dingdanhao like '%{txtOrderNo.Text.Trim()}%'");
            }
            if (ssbCust.Text.Trim().Length > 0)
            {
                wheres.Add($" kehu like '%{ssbCust.Text.Trim()}%'");
            }
            if (txtPartNo.Text.Trim().Length > 0)
            {
                wheres.Add($" chanpintuhao like '%{txtPartNo.Text.Trim()}%'");
            }
            if (txtPartName.Text.Trim().Length > 0)
            {
                wheres.Add($" chanpinmingcheng like '%{txtPartName.Text.Trim()}%'");
            }
            if (txtPageNo.Text.Trim().Length > 0)
            {
                wheres.Add($" tuzhiyema like '%{txtPageNo.Text.Trim()}%'");
            }

            var sql =
                "SELECT shigongdanhao 工单号,dingdanhao 生产单号,kehu 客户,jiaohuoqi 交货期,tuzhiyema 页码,DXFbianhao DXF," +
                "chanpintuhao 零件图号,chanpinmingcheng 零件名称,cailiao 材料,houdu 厚,changdu 长,kuandu 宽,dingdansuliang 下单数量," +
                "dantaoyongliang 单套用量,beizu 备注,gongyiliusheng 工艺流程,luodanriqi 下单日期,luodanyuan 录入人," +
                "xiugairiqi 修改日期,xiugairen 修改人,CASE WHEN cls_id='T' THEN '停用' ELSE '' END 是否停用,suhu 审核状态 FROM mf_sgdan ";

            //判断用户是否选择了条件
            if (wheres.Count > 0)
            {
                var where = string.Join(" AND ", wheres.ToArray());
                sql       = $"{sql} WHERE {@where} ORDER BY luodanriqi,dingdanhao,shigongdanhao";
            }
            _ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);
            dataGridView1.DataSource = _ds.Tables[0];
            dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending);
        }
Exemplo n.º 5
0
        private void Goiss()
        {
            const string sql = "SELECT id '序号',name '工序名称'FROM udbz ";
            var          ds  = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            dataGridView1.DataSource       = ds.Tables[0];
            dataGridView1.Columns[0].Width = 100;
            dataGridView1.Columns[1].Width = 100;
            dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
        }
        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();
            }
        }
Exemplo n.º 7
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 InitData()
        {
            const string sql =
                "SELECT a.ID,b.Team '班组名称',a.Name '员工' FROM PD_ProcCard_Employee a JOIN dbo.PD_ProcCard_Team b ON b.ID=a.TeamId ";
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnectionString("dzdj"), CommandType.Text, sql);

            dataGridView2.DataSource       = ds.Tables[0];
            dataGridView2.Columns[0].Width = 120;
            dataGridView2.Columns[1].Width = 200;
            dataGridView2.Columns[2].Width = 200;
            dataGridView2.Sort(dataGridView2.Columns[1], System.ComponentModel.ListSortDirection.Ascending);
        }
Exemplo n.º 9
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();
     }
 }
Exemplo n.º 10
0
        private void BindData()
        {
            var sql = $"SELECT Id,Team FROM PD_ProcCard_Team WHERE DeptId={SqlHelper.DeptId}";

            comboBox1.Items.Clear();
            comboBox1.Items.Add("");
            comboBox1.Text = "";
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnectionString("dzdj"), CommandType.Text, sql);

            comboBox1.DataSource    = ds.Tables[0];
            comboBox1.DisplayMember = "Team";
            comboBox1.ValueMember   = "Id";
        }
        private void FrmConstructionGather_Load(object sender, EventArgs e)
        {
            const string sql = "SELECT distinct cust FROM dzdj.dbo.customer";
            var          ds  = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            ssbCust.SpellSearchSource = GetSpellBoxSource(ds.Tables[0]).ToArray();
            var acsc = new AutoCompleteStringCollection();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                acsc.Add(dr["cust"].ToString());
            }
            ssbCust.AutoCompleteCustomSource = acsc;
        }
Exemplo n.º 12
0
        private void GetUserInfo()
        {
            panel1.Visible = false;
            panel2.Visible = false;
            const string sql = "SELECT lu as '序号',ID as '帐号',pass as '密码',name as '用户姓名',leiq as '用户类型' FROM IDPASS";
            var          ds  = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            dataGridView1.DataSource       = ds.Tables[0];
            dataGridView1.Columns[0].Width = 46;
            dataGridView1.Columns[1].Width = 80;
            dataGridView1.Columns[2].Width = 80;
            dataGridView1.Columns[3].Width = 80;
            dataGridView1.Columns[4].Width = 80;
            dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
        }
Exemplo n.º 13
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);
         }
     }
 }
Exemplo n.º 14
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();
        }
Exemplo n.º 15
0
        private void FrmPrint_Load(object sender, EventArgs e)
        {
            var sql = "SELECT a.*,c.Dept FROM udstr a LEFT JOIN dbo.udone b ON b.sgdhao=a.sgdhao " +
                      "LEFT JOIN DZDJ.dbo.TB_Dept c ON c.ID=b.DeptId " +
                      $"WHERE zling='{SqlHelper.ProcCardNo}' AND DeptId='{SqlHelper.DeptId}' ORDER BY a.gxone,a.gxtwo";

            SqlHelper.FillDataset(SqlHelper.GetConnection(), CommandType.Text, sql, _ds, new [] { "sql" });
            //var cr = new cncCryst();
            cncCryst1.Load(Application.StartupPath + "cncCryst.rpt");
            cncCryst1.SetDataSource(_ds.Tables[0]);
            //cr.SetParameterValue("procCardNo", SqlHelper.ProcCardNo);
            //cr.SetParameterValue("DeptId", SqlHelper.DeptId);

            //cr.ReportDocument.ParameterFields["Parm"].CurrentValues.AddValue(
            crystalReportViewer1.ReportSource = cncCryst1;
        }
Exemplo n.º 16
0
        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);
                    }
                }
            }
        }
        /// <summary>
        ///     工单单号变化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtWONo_TextChanged(object sender, EventArgs e)
        {
            if (txtWONo.Text.Length != 7)
            {
                return;
            }
            var sql =
                "SELECT shigongdanhao 工单号,dingdanhao 生产单号,kehu 客户,jiaohuoqi 交货期,tuzhiyema 页码,DXFbianhao DXF," +
                "chanpintuhao 零件图号,chanpinmingcheng 零件名称,cailiao 材料,houdu 厚,changdu 长,kuandu 宽,dingdansuliang 下单数量," +
                "dantaoyongliang 单套用量,beizu 备注,gongyiliusheng 工艺流程,luodanriqi 下单日期,luodanyuan 录入人," +
                "xiugairiqi 修改日期,xiugairen 修改人,CASE WHEN cls_id='T' THEN '停用' ELSE '' END 是否停用,suhu 审核状态 FROM " +
                $"mf_sgdan WHERE shigongdanhao='{txtWONo.Text.Trim()}'";
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql);

            dataGridView1.DataSource = ds.Tables[0];
            dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending);
        }
Exemplo n.º 18
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();
     }
 }
        /// <summary>
        ///     工单号变更事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtWONo_TextChanged(object sender, EventArgs e)
        {
            if (txtWONo.Text.Length != 7)
            {
                return;
            }
            var sql =
                "SELECT b.shigongdanhao '工单号',b.dingdanhao '生产单号',b.jiaohuoqi '订单交期',b.kehu '客户',b.tuzhiyema '页码',b.chanpintuhao '产品图号'," +
                "a.xuhao '工序号',a.gongxumingcheng '工序名称',a.shengchanyuan '生产班组',ISNULL(a.wanshengsuliang,0) '完成数量',a.jgsu '加工数'," +
                "RTRIM(a.xujah) '序价号',a.xujia '序价',a.buzu '补助',a.gongsi '公式类型',ISNULL(a.hezhi,0) '件资合计',a.lururiqi '录入日期'," +
                "RTRIM(a.luruyan) '录入人',a.qiugairiqi '修改日期',RTRIM(a.qgren) '修改人',RTRIM(a.suhu) '审核状态',RTRIM(a.suren) '审核人'," +
                "(CASE a.Checked WHEN 1 THEN '已核对' ELSE '' END) '核对状态',a.Checker '核对人',a.Chkdate '核对日期' " +
                $"FROM dbo.tf_sgdantwo a LEFT JOIN dbo.mf_sgdan b ON a.shigongdanhao=b.shigongdanhao WHERE a.shigongdanhao='{txtWONo.Text.Trim()}'";
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql);

            dataGridView1.DataSource = ds.Tables[0];
            dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending);
            //OnRowDataBound = "gvWOContent_RowDataBound";
        }
Exemplo n.º 20
0
 private void textBox4_TextChanged(object sender, EventArgs e)
 {
     if (textBox3.Text.Length == 4)
     {
         var sql = "SELECT zling as '工艺卡号',sgdhao as '工单号',ddhao as '生产单号',kehu as '客户'," +
                   "jhqi as '订单交期',tuhao as '产品图号', name as '产品名称',yema as '页码', cailiao as '材料'," +
                   "suliang as '订单数量',gxone as '序号',gxname as '工序名称',gxtwo as '加工工序',tiao as '调机时间'," +
                   "danjian as '单件加工',xuj as '序价',buzu as '补助',wssulia as '完成数量',hujii as '件资合计'," +
                   "wsbanz as'加工班组',bei3 as '生产员',wsriqi as '完成日期',cjriqi as '指令创日',lururiqi as '录入日期'," +
                   $"lururen as '录入人',qgriqi as '修改日期',qgren as '修改人' FROM udktr WHERE zling='{textBox4.Text.Trim()}'";
         var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);
         dataGridView1.DataSource        = ds.Tables[0];
         dataGridView1.Columns[0].Width  = 65;
         dataGridView1.Columns[1].Width  = 65;
         dataGridView1.Columns[2].Width  = 65;
         dataGridView1.Columns[3].Width  = 65;
         dataGridView1.Columns[4].Width  = 65;
         dataGridView1.Columns[5].Width  = 65;
         dataGridView1.Columns[6].Width  = 65;
         dataGridView1.Columns[7].Width  = 65;
         dataGridView1.Columns[8].Width  = 65;
         dataGridView1.Columns[9].Width  = 65;
         dataGridView1.Columns[10].Width = 65;
         dataGridView1.Columns[11].Width = 65;
         dataGridView1.Columns[12].Width = 65;
         dataGridView1.Columns[13].Width = 65;
         dataGridView1.Columns[14].Width = 90;
         dataGridView1.Columns[15].Width = 90;
         dataGridView1.Columns[16].Width = 65;
         dataGridView1.Columns[17].Width = 85;
         dataGridView1.Columns[18].Width = 65;
         dataGridView1.Columns[19].Width = 65;
         dataGridView1.Columns[20].Width = 65;
         dataGridView1.Columns[21].Width = 65;
         dataGridView1.Columns[22].Width = 65;
         dataGridView1.Columns[23].Width = 65;
         dataGridView1.Columns[24].Width = 65;
         dataGridView1.Columns[25].Width = 65;
         dataGridView1.Columns[26].Width = 65;
         dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
         //OnRowDataBound = "gvWOContent_RowDataBound";
     }
 }
Exemplo n.º 21
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();
         }
     }
 }
Exemplo n.º 22
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();
            }
        }
Exemplo n.º 23
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();
                }
            }
        }
        /// <summary>
        ///     根据条件查找
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch_Click(object sender, EventArgs e) //查询
        {
            CtrlUtil.ClearDgv(dataGridView1);

            var    wheres = new List <string>();
            string d;

            if (!string.IsNullOrEmpty(comboBox2.Text.Trim()))
            {
                d = comboBox2.SelectedValue.ToString();
            }
            else
            {
                MessageBox.Show(@"请选择一个日期选项!");
                comboBox2.DroppedDown = true;
                return;
            }
            if (!string.IsNullOrEmpty(dateTimePicker1.Text))
            {
                wheres.Add($" {d}>='{dateTimePicker1.Text}' ");
            }
            if (!string.IsNullOrEmpty(dateTimePicker2.Text))
            {
                var dtp = DateTime.Parse(dateTimePicker2.Text).AddDays(1);
                wheres.Add($" {d}<'{dtp}' ");
            }
            if (txtWONo.Text.Trim().Length > 0)
            {
                wheres.Add($" a.shigongdanhao like '%{txtWONo.Text.Trim()}%'");
            }
            if (txtMONo.Text.Trim().Length > 0)
            {
                wheres.Add($" b.dingdanhao like '%{txtMONo.Text.Trim()}%'");
            }
            if (txtPartNo.Text.Trim().Length > 0)
            {
                wheres.Add($" b.chanpintuhao like '%{txtPartNo.Text.Trim()}%'");
            }
            if (txtTeam.Text.Trim().Length > 0)
            {
                wheres.Add($" a.shengchanyuan like '%{txtTeam.Text.Trim()}%'");
            }
            if (txtCust.Text.Trim().Length > 0)
            {
                wheres.Add($" b.kehu like '%{txtCust.Text.Trim()}%'");
            }
            if (txtPage.Text.Trim().Length > 0)
            {
                wheres.Add($" b.tuzhiyema like '%{txtPage.Text.Trim()}%'");
            }
            if (checkBox3.Checked)
            {
                wheres.Add(" a.xujah like '%C15%'");
            }
            if (checkBox2.Checked)
            {
                wheres.Add(" a.xujah not like '%C15%'");
            }
            if (SqlHelper.UserType == Resources.UT_Input || SqlHelper.UserType == Resources.UT_Admin)
            {
                if (checkBox4.Checked)
                {
                    wheres.Add(" a.xujah like '%W11.1%'");
                }
                else if (checkBox5.Checked)
                {
                    wheres.Add(" a.xujah not like '%W11.1%'");
                }
            }

            if (comboBox1.Text.Trim().Length > 0)
            {
                if (comboBox1.Text.Trim() == Resources.UT_Audit)
                {
                    wheres.Add(" a.suhu ='审核'");
                }
                else if (comboBox1.Text.Trim() == "未审核")
                {
                    wheres.Add(" a.suhu is null or a.suhu =''");
                }
            }
            //string sql = "SELECT shigongdanhao as  '工单号',ddhao as '生产单号',kehu as '客户',jhqi as '订单交期',"+
            //    "chanpintuhao as '产品图号', xuhao as '工序号',gongxumingcheng as '工序名称',shengchanyuan as '生产班组',"+
            //    "wanshengsuliang as'完成数量',jgsu as '加工数',xujah as'序价号',xujia as '序价',buzu as '补助',"+
            //    "gongsi as '公式类型',hezhi as '件资合计',lururiqi as '录入日期',luruyan as '录入人',"+
            //    "qiugairiqi as '修改日期',qgren as '修改人',suhu as '审核状态',suren as '审核人' FROM tf_sgdantwo ";
            var sql =
                "SELECT b.shigongdanhao '工单号',b.dingdanhao '生产单号',b.jiaohuoqi '订单交期',b.kehu '客户',b.tuzhiyema '页码',b.chanpintuhao '产品图号'," +
                "a.xuhao '工序号',a.gongxumingcheng '工序名称',a.shengchanyuan '生产班组',ISNULL(a.wanshengsuliang,0) '完成数量',a.jgsu '加工数'," +
                "RTRIM(a.xujah) '序价号',a.xujia '序价',a.buzu '补助',a.gongsi '公式类型',ISNULL(a.hezhi,0) '件资合计',a.lururiqi '录入日期'," +
                "RTRIM(a.luruyan) '录入人',a.qiugairiqi '修改日期',RTRIM(a.qgren) '修改人',RTRIM(a.suhu) '审核状态',RTRIM(a.suren) '审核人'," +
                "(CASE a.Checked WHEN 1 THEN '已核对' ELSE '' END) '核对状态',a.Checker '核对人',a.Chkdate '核对日期' " +
                "FROM dbo.tf_sgdantwo a LEFT JOIN dbo.mf_sgdan b ON a.shigongdanhao=b.shigongdanhao ";

            //判断用户是否选择了条件
            if (wheres.Count > 0)
            {
                var wh = string.Join(" AND ", wheres.ToArray());
                sql = $"{sql} WHERE {wh} ORDER BY a.shigongdanhao,xuhao";
            }
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            dataGridView1.DataSource = ds.Tables[0];
            dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending);
        }
Exemplo n.º 25
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();
            }
        }
Exemplo n.º 26
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            textBox3.Text = "";
            textBox4.Text = "";
            var wheres = new List <string>();

            if (!string.IsNullOrEmpty(dateTimePicker3.Text))
            {
                wheres.Add($" lururiqi>='{dateTimePicker3.Text}' ");
            }
            if (!string.IsNullOrEmpty(dateTimePicker4.Text))
            {
                var dt = new DateTime();
                dt = DateTime.Parse(dateTimePicker4.Text).AddDays(1);
                wheres.Add($" lururiqi<'{dt}' ");
            }
            if (DateTime.Compare(dateTimePicker1.Value, dateTimePicker2.Value) < 0)
            {
                wheres.Add($" cjriqi>='{dateTimePicker1.Text}' ");
                var zdt = new DateTime();
                zdt = DateTime.Parse(dateTimePicker2.Text).AddDays(1);
                wheres.Add($" cjriqi<'{zdt}' ");
            }
            if (textBox1.Text.Trim().Length > 0)
            {
                wheres.Add($" ddhao like '%{textBox1.Text.Trim()}%'");
            }
            if (textBox2.Text.Trim().Length > 0)
            {
                wheres.Add($" kehu like '%{textBox2.Text.Trim()}%'");
            }
            if (textBox5.Text.Trim().Length > 0)
            {
                wheres.Add($" tuhao like '%{textBox5.Text.Trim()}%'");
            }
            if (textBox6.Text.Trim().Length > 0)
            {
                wheres.Add($" yema like '%{textBox6.Text.Trim()}%'");
            }
            if (textBox7.Text.Trim().Length > 0)
            {
                wheres.Add($" wsbanz like '%{textBox7.Text.Trim()}%'");
            }
            var sql = "SELECT zling as '工艺卡号',sgdhao as '工单号',ddhao as '生产单号',kehu as '客户'," +
                      "jhqi as '订单交期',tuhao as '产品图号', name as '产品名称',yema as '页码', cailiao as '材料'," +
                      "suliang as '订单数量',gxone as '序号',gxname as '工序名称',gxtwo as '加工工序',tiao as '调机时间'," +
                      "danjian as '单件加工',xuj as '序价',buzu as '补助',wssulia as '完成数量',hujii as '件资合计'," +
                      "wsbanz as'加工班组',bei3 as '生产员',wsriqi as '完成日期',cjriqi as '指令创日',lururiqi as '录入日期'," +
                      "lururen as '录入人',qgriqi as '修改日期',qgren as '修改人' FROM udktr";

            //判断用户是否选择了条件
            if (wheres.Count > 0)
            {
                var wh = string.Join(" AND ", wheres.ToArray());
                sql = $"{sql} WHERE {wh}ORDER BY zling, gxone,gxtwo";
            }
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            dataGridView1.DataSource        = ds.Tables[0];
            dataGridView1.Columns[0].Width  = 65;
            dataGridView1.Columns[1].Width  = 65;
            dataGridView1.Columns[2].Width  = 65;
            dataGridView1.Columns[3].Width  = 65;
            dataGridView1.Columns[4].Width  = 65;
            dataGridView1.Columns[5].Width  = 65;
            dataGridView1.Columns[6].Width  = 65;
            dataGridView1.Columns[7].Width  = 65;
            dataGridView1.Columns[8].Width  = 65;
            dataGridView1.Columns[9].Width  = 65;
            dataGridView1.Columns[10].Width = 65;
            dataGridView1.Columns[11].Width = 65;
            dataGridView1.Columns[12].Width = 65;
            dataGridView1.Columns[13].Width = 65;
            dataGridView1.Columns[14].Width = 90;
            dataGridView1.Columns[15].Width = 90;
            dataGridView1.Columns[16].Width = 65;
            dataGridView1.Columns[17].Width = 85;
            dataGridView1.Columns[18].Width = 65;
            dataGridView1.Columns[19].Width = 65;
            dataGridView1.Columns[20].Width = 65;
            dataGridView1.Columns[21].Width = 65;
            dataGridView1.Columns[22].Width = 65;
            dataGridView1.Columns[23].Width = 65;
            dataGridView1.Columns[24].Width = 65;
            dataGridView1.Columns[25].Width = 65;
            dataGridView1.Columns[26].Width = 65;
            dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
        }