/// <summary> /// 原始单号变更 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtOriWONo_TextChanged(object sender, EventArgs e) { if (txtOriWONo.Text.Length == 7) { var sql = $"SELECT TOP 1 * FROM mf_sgdan WHERE shigongdanhao='{txtOriWONo.Text.Trim()}'"; var dr = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (dr.HasRows) { dr.Read(); if (!String.IsNullOrEmpty(dr["suhu"].ToString().Trim()) || dr["cls_id"].ToString().Trim() == "T") { MessageBox.Show($"此工单号{txtOriWONo.Text.Trim()}已审核锁定,请重新输入或解锁!!", Resources.T提示); txtOriWONo.Text = ""; } else { cbxCust.Text = dr["kehu"].ToString().Trim(); txtOrderNo.Text = dr["dingdanhao"].ToString().Trim(); txtPartNo.Text = dr["chanpintuhao"].ToString().Trim(); txtPartName.Text = dr["chanpinmingcheng"].ToString().Trim(); dtpDelivery.Text = dr["jiaohuoqi"].ToString().Trim(); txtPageNo.Text = dr["tuzhiyema"].ToString().Trim(); txtOrderQt.Focus(); BindData(); } dr.Close(); } else { MessageBox.Show($"此工单号{txtOriWONo.Text.Trim()}不存在,请重新输入!!", Resources.T提示); txtOriWONo.Text = ""; } } }
private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (dataGridView1.SelectedRows != null) //当选中了行的时候才显示数据 { //将被点击的行的第一列的数据显示到第一个TextBox中 textBox16.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); //将被点击的行的第二列数据显示到第二个TextBox中,后面以此类推 textBox17.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString().Trim(); textBox18.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString().Trim(); textBox19.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString().Trim(); textBox20.Text = dataGridView1.SelectedRows[0].Cells[5].Value.ToString().Trim(); textBox21.Text = dataGridView1.SelectedRows[0].Cells[6].Value.ToString().Trim(); textBox22.Text = dataGridView1.SelectedRows[0].Cells[7].Value.ToString().Trim(); textBox23.Text = dataGridView1.SelectedRows[0].Cells[8].Value.ToString().Trim(); textBox24.Text = dataGridView1.SelectedRows[0].Cells[9].Value.ToString().Trim(); string sql = $"SELECT TOP 1 * FROM tf_sgdantwo WHERE shigongdanhao='{textBox15.Text.Trim()}'AND xuhao='{textBox16.Text.Trim()} '"; SqlDataReader a5C = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (a5C.HasRows) { a5C.Read(); _ak984 = a5C["xujah"].ToString().Trim(); _ak985 = a5C["xujia"].ToString().Trim(); _ak986 = a5C["buzu"].ToString().Trim(); a5C.Close(); } } }
private void textBox15_TextChanged(object sender, EventArgs e) { if (textBox15.Text.Length == 7) { string sql = $"SELECT TOP 1 * FROM mf_sgdan WHERE shigongdanhao='{textBox15.Text.Trim()}'"; SqlDataReader sdra5 = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (sdra5.HasRows) { sdra5.Read(); if (!String.IsNullOrEmpty(sdra5["suhu"].ToString().Trim())) { textBox1.Text = sdra5["kehu"].ToString().Trim(); textBox2.Text = sdra5["dingdanhao"].ToString().Trim(); textBox4.Text = sdra5["chanpintuhao"].ToString().Trim(); textBox6.Text = sdra5["chanpinmingcheng"].ToString().Trim(); textBox14.Text = sdra5["dingdansuliang"].ToString().Trim(); textBox3.Text = sdra5["jiaohuoqi"].ToString().Trim(); textBox5.Text = sdra5["tuzhiyema"].ToString().Trim(); sdra5.Close(); button2.Visible = true; button3.Visible = true; textBox15.ReadOnly = true; button2.Focus(); Goiss(); label3.Visible = true; MessageBox.Show($"此工单号{textBox15.Text.Trim()}已审核!!", "提示"); } else { textBox1.Text = sdra5["kehu"].ToString().Trim(); textBox2.Text = sdra5["dingdanhao"].ToString().Trim(); textBox4.Text = sdra5["chanpintuhao"].ToString().Trim(); textBox6.Text = sdra5["chanpinmingcheng"].ToString().Trim(); textBox14.Text = sdra5["dingdansuliang"].ToString().Trim(); textBox3.Text = sdra5["jiaohuoqi"].ToString().Trim(); textBox5.Text = sdra5["tuzhiyema"].ToString().Trim(); sdra5.Close(); button1.Visible = true; button2.Visible = true; button4.Visible = true; textBox15.ReadOnly = true; button1.Focus(); Goiss(); label3.Visible = false; } } else { MessageBox.Show($"此工单号{textBox15.Text.Trim()}不存在,请重新输入!!", "提示"); textBox15.Text = ""; sdra5.Close(); } } }
private void btnUpd_Click(object sender, EventArgs e)//修改 { _mMidtwo = dataGridView1.SelectedCells[0].Value.ToString().Trim(); //MMid = Convert.ToInt32(dataGridView1.SelectedCells[0].Value); panel3.Visible = false; panel2.Visible = true; var sql = $"SELECT * FROM xujia WHERE xujhao='{_mMidtwo}'"; var sdrtwo = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); sdrtwo.Read(); txtUPriceNo.Text = sdrtwo["xujhao"].ToString().Trim(); txtUPrice.Text = sdrtwo["xujia"].ToString().Trim(); txtUTeam.Text = sdrtwo["shiyong"].ToString().Trim(); txtUFormulaType.Text = sdrtwo["gongsi"].ToString().Trim(); txtUSubsidy.Text = sdrtwo["buzu"].ToString().Trim(); rtxUPriceDesc.Text = sdrtwo["beizu"].ToString().Trim(); }
private void btnSave_Click(object sender, EventArgs e)//新建保存 { if (txtAddPriceNo.Text != "") { if (txtAddPrice.Text != "" && txtAddFormulaType.Text != "") { var sql = $"SELECT xujhao FROM xujia WHERE xujhao='{txtAddPriceNo.Text.Trim()}'"; var sdddr2Q = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (sdddr2Q.HasRows) { MessageBox.Show($"此序价号< {txtAddPriceNo.Text.Trim()} >已存在,请重新输入!!", "提示"); txtAddPriceNo.Text = ""; txtAddPrice.Text = ""; txtAddTeam.Text = ""; txtAddSubsidy.Text = ""; txtAddFormulaType.Text = ""; rtxAPriceDesc.Text = ""; } else { sql = ""; sql = "insert into xujia(xujhao,xujia,buzu,shiyong,gongsi,beizu,cjren,cjriqi) values" + $"('{txtAddPriceNo.Text.Trim().ToUpper()}','{txtAddPrice.Text.Trim()}','{txtAddSubsidy.Text.Trim()}','{txtAddTeam.Text.Trim()}','{txtAddFormulaType.Text.Trim()}','{rtxAPriceDesc.Text.Trim()}','{SqlHelper.UserName}','{DateTime.Now}')"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); txtAddPriceNo.Text = ""; txtAddPrice.Text = ""; txtAddTeam.Text = ""; txtAddSubsidy.Text = ""; txtAddFormulaType.Text = ""; rtxAPriceDesc.Text = ""; BindData(); } } else { MessageBox.Show("序价与公式不能为空!", "提示"); txtAddPrice.Focus(); } } else { MessageBox.Show("序价号不能为空!", "提示"); txtAddPriceNo.Focus(); } }
/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (txtOrderQt.Text == "") { MessageBox.Show(@"工单数量不能为空!", Resources.T提示); txtOrderQt.Focus(); } else if (txtCraft.Text == "") { MessageBox.Show(@"工序名称不能为空!", Resources.T提示); txtCraft.Focus(); } else if (txtTeam.Text == "") { MessageBox.Show(@"生产班组不能为空!", Resources.T提示); txtTeam.Focus(); } else if (txtCompleteNum.Text == "") { MessageBox.Show(@"完成数量不能为空!", Resources.T提示); txtCompleteNum.Focus(); } else if (txtProcessNum.Text == "") { MessageBox.Show(@"加工数不能为空!", Resources.T提示); txtProcessNum.Focus(); } else if (txtPriceNo.Text == "") { MessageBox.Show(@"序价代码不能为空!", Resources.T提示); txtPriceNo.Focus(); } else { string[] arrCraftStr = { txtCraft.Text.Trim() }; var mergeTeamStr = MergeTeamStr(arrCraftStr, txtTeam.Text.Trim()); var sql = $"SELECT TOP 1 * FROM xujia WHERE xujhao='{txtPriceNo.Text.Trim()}'"; var dr = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (!dr.HasRows) { MessageBox.Show($"序价代码{txtPriceNo.Text.Trim()}不存在,请重新输入!!", Resources.T提示); txtPriceNo.Text = ""; txtPriceNo.Focus(); } else { dr.Read(); txtPrice.Text = dr["xujia"].ToString().Trim(); txtSubsidy.Text = dr["buzu"].ToString().Trim(); var formula = dr["gongsi"].ToString().Trim(); dr.Close(); if (txtOrderNo.Text.Trim() == "") { txtOrderNo.Text = txtWONo.Text.Trim(); } if (txtPriceNo.Text.Contains("C15") || txtPriceNo.Text.Contains("H1") || txtPriceNo.Text.Contains("Z1")) { sql = $"SELECT * FROM dzdj.dbo.bom WHERE customer='{txtTeam.Text.Trim()}' AND partno='{txtProcessNum.Text.Trim()}'"; dr = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (dr.HasRows) { dr.Read(); txtPrice.Text = txtPriceNo.Text.Contains("C15") ? dr["machuprice"].ToString().Trim() : @"0"; dr.Close(); } else { txtPrice.Text = @"0"; } } var uprice = decimal.Parse(txtPrice.Text.Trim()); var subsidy = decimal.Parse(txtSubsidy.Text.Trim()); var qt = decimal.Parse(txtCompleteNum.Text.Trim()); _processNum = txtProcessNum.Text.Trim() == "0" || txtProcessNum.Text.Trim() == "" ? 1M : decimal.Parse(txtProcessNum.Text.Trim()); decimal total; switch (formula) { case "1": total = qt * uprice * _processNum + subsidy; break; case "2": total = qt * uprice + subsidy; break; default: total = uprice * _processNum + subsidy; break; } var sn = decimal.Parse(txtSn.Text.Trim()); if (txtSn.Text.Trim() == "" || txtSn.Text.Trim() == "1") { sql = String.Format( "insert into mf_sgdan(shigongdanhao,dingdanhao,kehu,jiaohuoqi,tuzhiyema,chanpintuhao,chanpinmingcheng," + "dingdansuliang,beizu,twoid) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{0}')", txtWONo.Text.Trim(), txtOrderNo.Text.Trim(), cbxCust.Text.Trim(), dtpDelivery.Text.Trim(), txtPageNo.Text.Trim(), txtPartNo.Text.Trim(), txtPartName.Text.Trim(), txtOrderQt.Text.Trim(), txtOriWONo.Text.Trim()); SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); sql = "insert into tf_sgdantwo(shigongdanhao,xuhao,gongxumingcheng,chanpintuhao,shengchanyuan," + "wanshengsuliang,jgsu,xujah,xujia,buzu,hezhi,lururiqi,luruyan,kehu,ddhao,jhqi,gongsi,jihuariqi) values" + $"('{txtWONo.Text.Trim()}','{txtSn.Text.Trim()}','{txtCraft.Text.Trim()}','{txtPartNo.Text.Trim()}','{mergeTeamStr}','{txtCompleteNum.Text.Trim()}','{txtProcessNum.Text.Trim()}','{txtPriceNo.Text.Trim().ToUpper()}','{txtPrice.Text.Trim()}','{txtSubsidy.Text.Trim()}','{total}','{DateTime.Now}','{SqlHelper.UserName}','{cbxCust.Text.Trim()}','{txtOrderNo.Text.Trim()}','{dtpDelivery.Text.Trim()}','{formula}',{0})"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); EnableCtrls(true); txtCraft.Text = ""; txtTeam.Text = ""; txtCompleteNum.Text = ""; txtProcessNum.Text = ""; txtPriceNo.Text = ""; txtPrice.Text = ""; txtSubsidy.Text = ""; sn += 1; txtSn.Text = sn.ToString(CultureInfo.InvariantCulture); BindData(); txtCraft.Focus(); } else { sql = $"SELECT count(*) icount FROM tf_sgdantwo WHERE gongxumingcheng='{txtCraft.Text.Trim()}' AND shigongdanhao='{txtWONo.Text.Trim()} '" + $" AND xujah='{txtPriceNo.Text.Trim()} 'AND buzu>0 "; dr = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (dr.HasRows) { dr.Read(); if ((int)dr["icount"] > 0) { txtSubsidy.Text = @"0"; } dr.Close(); } subsidy = decimal.Parse(txtSubsidy.Text.Trim()); switch (formula) { case "1": total = qt * uprice * _processNum + subsidy; break; case "2": total = qt * uprice + subsidy; break; default: total = uprice * _processNum + subsidy; break; } sql = "insert into tf_sgdantwo(shigongdanhao,xuhao,gongxumingcheng,chanpintuhao,shengchanyuan," + "wanshengsuliang,jgsu,xujah,xujia,buzu,hezhi,lururiqi,luruyan,kehu,ddhao,jhqi,gongsi,jihuariqi) values" + $"('{txtWONo.Text.Trim()}','{txtSn.Text.Trim()}','{txtCraft.Text.Trim()}','{txtPartNo.Text.Trim()}','{mergeTeamStr}','{txtCompleteNum.Text.Trim()}','{txtProcessNum.Text.Trim()}','{txtPriceNo.Text.Trim().ToUpper()}','{txtPrice.Text.Trim()}','{txtSubsidy.Text.Trim()}','{total}','{DateTime.Now}','{SqlHelper.UserName}','{cbxCust.Text.Trim()}','{txtOrderNo.Text.Trim()}','{dtpDelivery.Text.Trim()}','{formula}',{0})"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); txtCraft.Text = ""; txtTeam.Text = ""; txtCompleteNum.Text = ""; txtProcessNum.Text = ""; txtPriceNo.Text = ""; txtPrice.Text = ""; txtSubsidy.Text = ""; sn += 1; txtSn.Text = sn.ToString(CultureInfo.InvariantCulture); txtCraft.Focus(); BindData(); } } dr.Close(); } }
private void textBox21_KeyDown(object sender, KeyEventArgs e) { if (textBox16.Text != "" & textBox17.Text != "") { if (e.KeyCode == Keys.Enter) { string sql = $"SELECT TOP 1 * FROM xujia WHERE xujhao='{textBox21.Text.Trim()}'"; SqlDataReader ac = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (ac.HasRows) { ac.Read(); textBox22.Text = ac["xujia"].ToString().Trim(); textBox24.Text = ac["gongsi"].ToString().Trim(); _ak7948 = ac["buzu"].ToString().Trim(); ac.Close(); //MessageBox.Show(ak97, "提示"); sql = ""; sql = $"SELECT count(*) icount FROM tf_sgdantwo WHERE gongxumingcheng='{textBox17.Text.Trim()}' AND shigongdanhao='{textBox15.Text.Trim()}' " + $"AND xujah='{textBox21.Text.Trim()}' AND buzu>0 "; SqlDataReader g2 = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (g2.HasRows) { g2.Read(); if ((int)g2["icount"] > 0) { if (_ak986 == _ak7948) { g2.Close(); textBox23.Text = _ak986; textBox20.Focus(); } else { textBox23.Text = "0"; //MessageBox.Show(ak798, "提示"); g2.Close(); textBox20.Focus(); } } else { textBox23.Text = _ak7948; g2.Close(); textBox20.Focus(); } } string sKl = textBox21.Text.Trim().ToUpper(); if (sKl.Contains("C15")) { textBox22.ReadOnly = false; } else { textBox22.ReadOnly = true; } } else { MessageBox.Show($"序价代码{textBox21.Text.Trim()}不存在,请重新输入!!", "提示"); textBox21.Text = ""; textBox21.Focus(); ac.Close(); } } } else { MessageBox.Show("请先选择行数据", "提示"); } }
private void button4_Click(object sender, EventArgs e) { if (panel1.Visible == false) { button4.Text = "&X保存"; label14.Visible = true; panel1.Visible = true; panel2.Visible = false; button1.Visible = false; button2.Visible = false; button5.Visible = true; textBox22.ReadOnly = true; } else { if (textBox16.Text != "" & textBox17.Text != "") { if (textBox18.Text != "") { if (textBox19.Text != "") { if (textBox20.Text != "") { if (textBox22.Text != "") { if (textBox21.Text != "") { string sql = $"SELECT TOP 1 * FROM xujia WHERE xujhao='{textBox21.Text.Trim()}'"; SqlDataReader a3C = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (a3C.HasRows) { a3C.Read(); _ak798 = a3C["xujia"].ToString().Trim(); textBox24.Text = a3C["gongsi"].ToString().Trim(); _ak7948 = a3C["buzu"].ToString().Trim(); a3C.Close(); string sKl = textBox21.Text.Trim().ToUpper(); if (sKl.Contains("C15") & textBox22.Text.Trim() != _ak798 & textBox22.ReadOnly == false) { } else { textBox22.Text = _ak798; } sql = ""; sql = $"SELECT count(*) icount FROM tf_sgdantwo WHERE gongxumingcheng='{textBox17.Text.Trim()}' AND shigongdanhao='{textBox15.Text.Trim()}' " + $"AND xujah='{textBox21.Text.Trim()} 'AND buzu>0 "; SqlDataReader g2 = SqlHelper.ExecuteReader(SqlHelper.GetConnection(), CommandType.Text, sql); if (g2.HasRows) { g2.Read(); if ((int)g2["icount"] > 0) { if (_ak986 == _ak7948) { textBox23.Text = _ak986; g2.Close(); } else { textBox23.Text = "0"; g2.Close(); } } else { textBox23.Text = _ak7948; g2.Close(); } } decimal fIko = decimal.Parse(textBox19.Text.Trim()); decimal fIkp = decimal.Parse(textBox20.Text.Trim()); decimal fIks = decimal.Parse(textBox22.Text.Trim()); decimal fIkt = decimal.Parse(textBox23.Text.Trim()); decimal fIkf; textBox22.ReadOnly = true; if (textBox24.Text.Trim() == "1") { fIkf = fIko * fIkp * fIks + fIkt; } else if (textBox24.Text.Trim() == "2") { fIkf = fIko * fIks + fIkt; } else { fIkf = fIkp * fIks + fIkt; } sql = ""; sql = $"UPDATE tf_sgdantwo set shengchanyuan='{textBox18.Text.Trim().ToUpper()}',wanshengsuliang='{textBox19.Text.Trim()}',wyqg='{SqlHelper.UserName}',gongsi='{textBox24.Text.Trim()}'," + $"jgsu='{textBox20.Text.Trim()}',hezhi='{fIkf}',wyrq='{DateTime.Now}',xujah='{textBox21.Text.Trim().ToUpper()}',xujia='{textBox22.Text.Trim()}',buzu='{textBox23.Text.Trim()}' WHERE shigongdanhao ='{textBox15.Text.Trim()}' AND " + $"xuhao='{textBox16.Text.Trim()}'"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); button1.Visible = true; button2.Visible = true; button3.Visible = false; button4.Visible = true; button5.Visible = false; panel1.Visible = false; panel2.Visible = true; label14.Visible = false; button4.Text = "&X修改"; textBox16.Text = ""; textBox17.Text = ""; textBox18.Text = ""; textBox19.Text = ""; textBox20.Text = ""; textBox21.Text = ""; textBox22.Text = ""; textBox23.Text = ""; textBox24.Text = ""; Goiss(); } else { MessageBox.Show($"序价代码{textBox21.Text.Trim()}不存在,请重新输入!!", "提示"); textBox21.Text = ""; textBox22.Text = ""; textBox23.Text = ""; textBox24.Text = ""; textBox21.Focus(); a3C.Close(); } } else { MessageBox.Show("序价代码不能为空!", "提示"); textBox21.Focus(); } } else { MessageBox.Show("序价不能为空!", "提示"); textBox22.Focus(); } } else { MessageBox.Show("加工数不能为空!", "提示"); textBox20.Focus(); } } else { MessageBox.Show("完成数量不能为空!", "提示"); textBox19.Focus(); } } else { MessageBox.Show("生产班组不能为空!", "提示"); textBox18.Focus(); } } else { MessageBox.Show("请先选择行数据", "提示"); } } }