예제 #1
0
 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();
         }
     }
 }
예제 #2
0
        /// <summary>
        ///     新增
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInsert_Click(object sender, EventArgs e)
        {
            var orderId = DateTime.Now.ToString("yyMM").Substring(1, 3);
            var ddaa    = orderId + "0001";
            var aadd    = orderId + "9999";
            var sql     = $"SELECT Max(twoid) FROM mf_sgdan WHERE twoid>={ddaa} AND twoid<={aadd}";
            var scalar  = SqlHelper.ExecuteScalar(SqlHelper.GetConnection(), CommandType.Text, sql);

            if (scalar.ToString() == "")
            {
                txtWONo.Text      = ddaa;
                btnInsert.Enabled = false;
                btnSave.Enabled   = true;
                txtOriWONo.Focus();
                txtSn.Text = @"1";
            }
            else
            {
                if (scalar.ToString() == aadd)
                {
                    MessageBox.Show(@"手工工单已经达到9999份上限,编号要重新生成!", Resources.T提示);
                }
                else
                {
                    var maxtid = (int)scalar;
                    maxtid           += 1;
                    txtWONo.Text      = maxtid.ToString();
                    btnInsert.Enabled = false;
                    btnSave.Enabled   = true;
                    txtOriWONo.Focus();
                    txtSn.Text = @"1";
                }
            }
            EnableCtrls(true);
        }
예제 #3
0
 private void Goiss()
 {
     if (textBox15.Text.Trim() != "")
     {
         string sql = "SELECT xuhao as '工序号',gongxumingcheng as '工序名称',jihuariqi 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 '修改人' FROM tf_sgdantwo " +
                      $"WHERE shigongdanhao='{textBox15.Text.Trim()}'";
         DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);
         dataGridView1.DataSource        = ds.Tables[0];
         dataGridView1.Columns[0].Width  = 60;
         dataGridView1.Columns[1].Width  = 75;
         dataGridView1.Columns[2].Width  = 90;
         dataGridView1.Columns[3].Width  = 70;
         dataGridView1.Columns[4].Width  = 60;
         dataGridView1.Columns[5].Width  = 60;
         dataGridView1.Columns[6].Width  = 60;
         dataGridView1.Columns[7].Width  = 60;
         dataGridView1.Columns[8].Width  = 50;
         dataGridView1.Columns[9].Width  = 50;
         dataGridView1.Columns[10].Width = 100;
         dataGridView1.Columns[11].Width = 100;
         dataGridView1.Columns[12].Width = 60;
         dataGridView1.Columns[13].Width = 100;
         dataGridView1.Columns[14].Width = 60;
         dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
     }
 }
예제 #4
0
 /// <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 = "";
         }
     }
 }
예제 #5
0
        /// <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));
        }
예제 #6
0
 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();
         }
     }
 }
예제 #7
0
        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();
            }
        }
예제 #9
0
 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();
     }
 }
예제 #10
0
        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();
        }
예제 #11
0
 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();
     }
 }
예제 #12
0
        /// <summary>
        ///     DataGridView的绑定数据
        /// </summary>
        private void BindData()
        {
            _wono = txtWONo.Text.Trim();
            if (_wono == "")
            {
                return;
            }
            var sql = "SELECT xuhao '工序号',gongxumingcheng '工序名称',jihuariqi '计划完成日期'," +
                      "shengchanyuan '生产班组',wanshengsuliang '完成数量',jgsu '加工数',xujah '序价号',xujia '序价'," +
                      "buzu '补助',hezhi '件资合计',lururiqi '录入日期',luruyan '录入人',qiugairiqi '修改日期'," +
                      $"qgren '修改人' FROM tf_sgdantwo WHERE shigongdanhao='{txtWONo.Text.Trim()}'";
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            dataGridView1.DataSource = ds.Tables[0];
            dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Ascending);
            if (IsChecked(_wono))
            {
                lblCheck.Visible = true;
            }
        }
        private void BindData()
        {
            var sql = $"SELECT Craft FROM PD_ProcCard_UPrice WHERE DeptId='{SqlHelper.DeptId}' ORDER BY ID";
            var ds  = SqlHelper.ExecuteDataset(SqlHelper.GetConnectionString("dzdj"), CommandType.Text, sql);

            cbxCraft.DataSource    = ds.Tables[0];
            cbxCraft.DisplayMember = "Craft";
            cbxCraft.ValueMember   = "Craft";
            sql = "SELECT IDO '流水',iname '工序名称',qtime '时间起',ztime '时间止'," +
                  "jilu '单价基数',jisu '计算折率',beizu '备注' FROM udodt  ORDER BY iname , ztime ";
            ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);
            dataGridView1.DataSource       = ds.Tables[0];
            dataGridView1.Columns[0].Width = 60;
            dataGridView1.Columns[1].Width = 80;
            dataGridView1.Columns[2].Width = 80;
            dataGridView1.Columns[3].Width = 80;
            dataGridView1.Columns[4].Width = 80;
            dataGridView1.Columns[5].Width = 80;
            dataGridView1.Columns[6].Width = 200;
            dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
        }
예제 #14
0
 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();
     }
 }
예제 #15
0
        private void BindData()
        {
            panel1.Visible = false;
            panel2.Visible = false;
            panel3.Visible = true;

            const string sql = "SELECT xujhao '序价号',xujia '序价',buzu '补助',gongsi '公式'," +
                               "shiyong '适用班组',beizu '序价说明',cjren '创建',cjriqi '创建日期',qgren '修改',qgriqi '修改日期' FROM xujia ";
            var ds = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.Text, sql);

            dataGridView1.DataSource       = ds.Tables[0];
            dataGridView1.Columns[0].Width = 80;
            dataGridView1.Columns[1].Width = 80;
            dataGridView1.Columns[2].Width = 80;
            dataGridView1.Columns[3].Width = 55;
            dataGridView1.Columns[4].Width = 80;
            dataGridView1.Columns[5].Width = 222;
            dataGridView1.Columns[6].Width = 55;
            dataGridView1.Columns[7].Width = 80;
            dataGridView1.Columns[8].Width = 55;
            dataGridView1.Columns[9].Width = 80;
            dataGridView1.Sort(dataGridView1.Columns[0], System.ComponentModel.ListSortDirection.Ascending);
        }
예제 #16
0
 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("请先选择行数据", "提示");
         }
     }
 }
예제 #17
0
        /// <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();
            }
        }
예제 #18
0
 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 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     = "";
     }
 }