/// <summary> /// 核对 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCheck_Click(object sender, EventArgs e) { _wono = txtWONo.Text.Trim(); var isChecked = IsChecked(_wono) ? 0 : 1; var sql = $"UPDATE tf_sgdantwo set Checked={isChecked},Checker='{SqlHelper.UserName}',Chkdate='{DateTime.Now}' WHERE shigongdanhao ='{_wono}'"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); EnableCtrls(!Convert.ToBoolean(isChecked)); }
private void button3_Click(object sender, EventArgs e)//弃审 { string sql = $"UPDATE mf_sgdan set suhu='' WHERE shigongdanhao ='{textBox15.Text.Trim()}'"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); sql = ""; sql = $"UPDATE tf_sgdantwo set suhu='',suren='' WHERE shigongdanhao ='{textBox15.Text.Trim()}'"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); button1.Visible = true; button2.Visible = true; button3.Visible = false; button4.Visible = true; label3.Visible = false; }
private void button3_Click(object sender, EventArgs e) { var kMMi = dataGridView1.SelectedCells[0].Value.ToString().Trim(); if (MessageBox.Show("是否要删除所选择的行", Resources.J警告, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { var sql = $"delete FROM udodt WHERE IDO='{kMMi}'"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); BindData(); } else { BindData(); } }
private void btnDel_Click(object sender, EventArgs e)//删除 { if (dataGridView1.SelectedRows.Count == 0) { MessageBox.Show("提示:请选择要删除的用户信息!", "警告"); } else { var mMidtwo = dataGridView1.SelectedCells[0].Value.ToString().Trim(); if (MessageBox.Show($"是否要删除< {mMidtwo} >序价号", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { var sql = $"delete FROM xujia WHERE xujhao='{mMidtwo}'"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); } BindData(); } }
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(); } }
private void btnUpdSave_Click(object sender, EventArgs e)//修改保存 { if (txtUPriceNo.Text != "" && txtUFormulaType.Text != "") { var sql = $"UPDATE xujia set xujia='{txtUPrice.Text.Trim()}',gongsi='{txtUFormulaType.Text.Trim()}',buzu='{txtUSubsidy.Text.Trim()}',shiyong='{txtUTeam.Text.Trim()}',beizu='{rtxUPriceDesc.Text.Trim()}'," + $"qgren='{SqlHelper.UserName}',qgriqi='{DateTime.Now}' WHERE xujhao='{_mMidtwo}'"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); txtUTeam.Text = ""; txtUPrice.Text = ""; txtUPriceNo.Text = ""; txtUSubsidy.Text = ""; txtUFormulaType.Text = ""; rtxUPriceDesc.Text = ""; BindData(); } else { MessageBox.Show("序价与公式不能为空!", "提示"); txtUPrice.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 button6_Click(object sender, EventArgs e) { if (button6.Text == Resources.X保存) { if (cbxCraft.Text != "") { if (textBox7.Text != "") { if (textBox2.Text != "") { if (textBox3.Text != "") { if (textBox4.Text != "") { var lMi = dataGridView1.SelectedCells[0].Value.ToString().Trim(); var sql = $"UPDATE udodt set iname='{cbxCraft.Text.Trim().ToUpper()}',qtime='{decimal.Parse(textBox7.Text.Trim())}',ztime='{decimal.Parse(textBox2.Text.Trim())}',jilu='{decimal.Parse(textBox3.Text.Trim())}',jisu='{decimal.Parse(textBox4.Text.Trim())}'," + $"beizu='{textBox5.Text.Trim()}' WHERE IDO ='{lMi}'"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); BindData(); button6.Text = Resources.X修改; button1.Visible = true; button3.Visible = true; textBox2.ReadOnly = true; textBox3.ReadOnly = true; textBox4.ReadOnly = true; textBox5.ReadOnly = true; textBox7.ReadOnly = true; cbxCraft.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; } else { MessageBox.Show("计算折率不能为空", Resources.T提示); textBox4.Focus(); } } else { MessageBox.Show("单价基数不能为空", Resources.T提示); textBox3.Focus(); } } else { MessageBox.Show("时间止不能为空", Resources.T提示); textBox2.Focus(); } } else { MessageBox.Show("时间起不能为空", Resources.T提示); textBox7.Focus(); } } else { MessageBox.Show("请先选择所要修改的项目行", Resources.T提示); cbxCraft.Focus(); } } else { button6.Text = Resources.X保存; button1.Visible = false; button3.Visible = false; textBox2.ReadOnly = false; textBox3.ReadOnly = false; textBox4.ReadOnly = false; textBox5.ReadOnly = false; textBox7.ReadOnly = false; cbxCraft.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; } }
private void button1_Click(object sender, EventArgs e) { if (button1.Text == Resources.A保存) { if (cbxCraft.Text != "") { if (textBox7.Text != "") { if (textBox2.Text != "") { if (textBox3.Text != "") { if (textBox4.Text != "") { var sql = $"insert into udodt(iname,qtime,ztime,jilu,jisu,beizu) values('{cbxCraft.Text.Trim().ToUpper()}','{decimal.Parse(textBox7.Text.Trim())}','{decimal.Parse(textBox2.Text.Trim())}'," + $"'{decimal.Parse(textBox3.Text.Trim())}','{decimal.Parse(textBox4.Text.Trim())}','{textBox5.Text.Trim()}')"; SqlHelper.ExecuteNonQuery(SqlHelper.GetConnection(), CommandType.Text, sql); button1.Text = Resources.A新增; button6.Visible = true; button3.Visible = true; textBox2.ReadOnly = true; textBox3.ReadOnly = true; textBox4.ReadOnly = true; textBox5.ReadOnly = true; textBox7.ReadOnly = true; cbxCraft.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; BindData(); } else { MessageBox.Show("计算折率不能为空", Resources.T提示); textBox4.Focus(); } } else { MessageBox.Show("单价基数不能为空", Resources.T提示); textBox3.Focus(); } } else { MessageBox.Show("时间止不能为空", Resources.T提示); textBox2.Focus(); } } else { MessageBox.Show("时间起不能为空", Resources.T提示); textBox7.Focus(); } } else { MessageBox.Show("工序名称不能为空", Resources.T提示); cbxCraft.Focus(); } } else { button1.Text = Resources.A保存; button6.Visible = false; button3.Visible = false; textBox2.ReadOnly = false; textBox3.ReadOnly = false; textBox4.ReadOnly = false; textBox5.ReadOnly = false; textBox7.ReadOnly = false; cbxCraft.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; } }
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("请先选择行数据", "提示"); } } }