Ejemplo n.º 1
0
 private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
 {
     for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
     {
         if (!Globals.CheckNumber(dataGridView1.Rows[i].Cells["使用长度"].ErrorText))
         {
             MessageBox.Show("使用长度必须为数字!");
             return;
         }
     }
 }
Ejemplo n.º 2
0
        private void dataGridView1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter & dataGridView1.CurrentCell.ColumnIndex == 0)//是否选择的是第一个单元格
            {
                //验证不通过
                try
                {
                    if (!yanzheng(dataGridView1.CurrentRow.Cells["tm"].Value.ToString(), dataGridView1.CurrentCell.RowIndex))
                    {
                        dataGridView1.CurrentRow.Cells["tm"].Value = "";
                        return;
                    }

                    // dataGridView1.CurrentCell
                    //扫描原料条码  在dt_ycl中 查询
                    if (dt_gxl.Rows.Count != 0)
                    {
                        try
                        {
                            DataRow[] drArr = dt_gxl.Select("条码 = '" + dataGridView1.CurrentCell.Value.ToString().Trim() + "'");

                            dataGridView1.CurrentRow.Cells["kycd"].Value = drArr[0]["可用长度"];//膜长
                            // dataGridView1.CurrentRow.Cells["sycd1"].Value = drArr[0]["kycd"];//膜长
                            dataGridView1.CurrentCell = dataGridView1[4, dataGridView1.CurrentCell.RowIndex];
                            dataGridView1.CurrentRow.Cells["mk"].Value = drArr[0]["膜宽"];
                            dataGridView1.CurrentRow.Cells["mh"].Value = drArr[0]["膜厚"];
                            //dataGridView1.CurrentRow.Cells[""].Value = drArr[0][""];
                            //dataGridView1.CurrentRow.Cells[""].Value = drArr[0][""];
                            //dataGridView1.CurrentRow.Cells[""].Value = drArr[0][""];
                        }
                        catch
                        {
                            MessageBox.Show("错误的条码,请重新扫描");
                            dataGridView1.CurrentRow.Cells["tm"].Value = "";
                        }
                        return;
                    }
                    else
                    {
                        MessageBox.Show("请先做生产领料单");
                    }
                }
                catch {
                    MessageBox.Show("错误的条码");
                    return;
                }
            }
            if (e.KeyCode == Keys.Enter & dataGridView1.CurrentCell.ColumnIndex == 4)//是否选择的是第6个单元格
            {
                if (!Globals.CheckNumber(dataGridView1.CurrentRow.Cells["sycd1"].Value.ToString().Trim()))
                {
                    MessageBox.Show("请输入数字");
                    dataGridView1.CurrentRow.Cells["sycd1"].Value = null;
                    return;
                }
                if (decimal.Parse(dataGridView1.CurrentRow.Cells["sycd1"].Value.ToString().Trim()) > decimal.Parse(dataGridView1.CurrentRow.Cells["kycd"].Value.ToString().Trim()))
                {
                    MessageBox.Show("使用长度不能超过膜长度");
                    dataGridView1.CurrentRow.Cells["sycd1"].Value = null;
                    return;
                }
            }
        }
Ejemplo n.º 3
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            // FPt pt1 = new FPt("", 1);
            if (dataGridView1.RowCount <= 1)
            {
                MessageBox.Show("信息不全不能保存");
                return;
            }
            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                if (dataGridView1.Rows[i].Cells["sycd1"].Value == null)
                {
                    MessageBox.Show("使用长度必须为数字");

                    return;
                }

                if (!Globals.CheckNumber(dataGridView1.Rows[i].Cells["sycd1"].Value.ToString().Trim()))
                {
                    MessageBox.Show("使用长度必须为数字");

                    return;
                }
                if (decimal.Parse(dataGridView1.Rows[i].Cells["sycd1"].Value.ToString().Trim()) > decimal.Parse(dataGridView1.Rows[i].Cells["kycd"].Value.ToString().Trim()))
                {
                    MessageBox.Show("使用长度不能超可用长度");
                    dataGridView1.Rows[i].Cells["sycd1"].Value           = null;
                    dataGridView1.Rows[i].Cells["sycd1"].Style.BackColor = Color.Red;

                    return;
                }
            }


            if (MessageBox.Show("是否需要保存", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;  //否就退出操作
            }

            if (js.Text != "")
            {
                if (!Globals.CheckNumber(js.Text.ToString().Trim()))
                {
                    MessageBox.Show("卷数必须为数字");
                    js.Text = null;
                    return;
                }
            }
            else
            {
                MessageBox.Show("卷数必须录入");
                // mkd.Text = null;
                return;
            }
            if (mcd.Text != "")
            {
                if (!Globals.CheckNumber(mcd.Text.ToString().Trim()))
                {
                    MessageBox.Show("膜长度必须为数字");
                    mkd.Text = null;
                    return;
                }
            }
            else
            {
                MessageBox.Show("膜长度必须录入");
                return;
            }
            if (qds.Text != "")
            {
                if (!Globals.CheckNumber(qds.Text.ToString().Trim()))
                {
                    MessageBox.Show("刀数必须为数字");
                    qds.Text = null;
                    return;
                }
            }
            else
            {
                MessageBox.Show("刀数必须录入");
                return;
            }
            if (dataGridView1.RowCount < 1)
            {
                MessageBox.Show("信息不全不能保存");
                return;
            }
            try
            {
                ds.Tables["tgx"].Clear();
            }
            catch { }
            try
            {
                ds.Tables["gxb"].Clear();
            }
            catch { }
            string         insertsql = "SELECT  FBarcode, FWork, FQty, FMcd, FMkd, FMhd, FJs, FBc, FJyy, FBz, FUnitID, FICMOID, FItemID, FJlr, FJlrq,FRkd, FSfrk, FSfyw, FICMOBillNo ,FBatchNo ,FMustSh,Fjh,Fds,FXh FROM  Tgx where 1=2 ";
            SqlDataAdapter gxjl      = new SqlDataAdapter(insertsql, conn);

            gxjl.Fill(ds, "tgx");
            SqlCommandBuilder sb1    = new SqlCommandBuilder(gxjl);
            string            sql    = "select fyctm,fsycd,FCptm from Tylcpgx  where 1=2";//保存对应关系到Tylcpgx表
            SqlDataAdapter    dtylgx = new SqlDataAdapter(sql, conn);

            dtylgx.Fill(ds, "gxb");//过程记录表

            SqlCommandBuilder sb = new SqlCommandBuilder(dtylgx);
            DataRow           newrowgx;
            DataRow           newrow;
            string            tm;
            string            tmhb = "";


            string    sqlmax  = "select FXh ,FJlrq from tgx  where FICMOBillNo='" + comboBox1.SelectedValue + "' and FWork='分切'  order  by FXh desc";
            DataTable maxdata = sj.ds(sqlmax, "zdz", conn);

            if (maxdata.Rows.Count < 1)
            {
                zxh.Text  = "1";
                jlrq.Text = DateTime.Now.ToString();
            }
            else
            {
                zxh.Text  = (int.Parse(maxdata.Rows[0][0].ToString()) + 1).ToString();
                jlrq.Text = maxdata.Rows[0][1].ToString();
            }



            for (int j = 0; j < int.Parse(qds.Text.Trim()); j++)    //刀数控制
            {
                for (int i = 0; i < int.Parse(js.Text.Trim()); i++) //卷数控制
                {
                    newrowgx = ds.Tables["tgx"].NewRow();

                    newrowgx["FBarcode"] = tm = wl.Text.PadLeft(5, '0') + Globals.GetTimeStamp();
                    for (int k = 0; k < dataGridView1.RowCount - 1; k++)
                    {
                        newrow          = ds.Tables["gxb"].NewRow();
                        newrow["fcptm"] = newrowgx["FBarcode"];
                        newrow["fyctm"] = dataGridView1.Rows[k].Cells["tm"].Value.ToString();

                        try
                        {
                            if (dataGridView1.Rows[i].Cells["yw"].Value.ToString() == "是")
                            {
                                newrow["fsycd"] = (decimal.Parse(dataGridView1.Rows[k].Cells["kycd"].Value.ToString()) / int.Parse(js.Text.Trim()) / int.Parse(qds.Text.Trim())).ToString(("#0.0000"));
                            }
                            else
                            {
                                newrow["fsycd"] = (decimal.Parse(dataGridView1.Rows[k].Cells["sycd1"].Value.ToString()) / int.Parse(js.Text.Trim()) / int.Parse(qds.Text.Trim())).ToString(("#0.0000"));
                            }
                        }
                        catch
                        {
                            newrow["fsycd"] = (decimal.Parse(dataGridView1.Rows[k].Cells["sycd1"].Value.ToString()) / int.Parse(js.Text.Trim()) / int.Parse(qds.Text.Trim())).ToString(("#0.0000"));
                        }


                        // newrow["fsycd"] = (decimal.Parse(dataGridView1.Rows[k].Cells["sycd1"].Value.ToString()) / int.Parse(js.Text.Trim()) / int.Parse(qds.Text.Trim())).ToString(("#0.0000"));
                        ds.Tables["gxb"].Rows.Add(newrow);
                    }

                    tmhb += tm + "|";
                    Thread.Sleep(1);
                    newrowgx["FWork"] = "分切";
                    if (mzl.Text != "")
                    {
                        newrowgx["fqty"] = mzl.Text.Trim();
                    }
                    if (mcd.Text != "")
                    {
                        newrowgx["fmcd"] = mcd.Text.Trim();
                    }
                    if (mkd.Text != "")
                    {
                        newrowgx["fmkd"] = mkd.Text.Trim();
                    }
                    if (mhd.Text != "")
                    {
                        newrowgx["FMhd"] = mhd.Text.Trim();
                    }
                    newrowgx["fbc"]         = bc.Text;
                    newrowgx["FJyy"]        = jyy.Text;
                    newrowgx["fbz"]         = bz.Text;
                    newrowgx["FJlr"]        = jlr.Text;
                    newrowgx["FJlrq"]       = jlrq.Text;
                    newrowgx["FItemID"]     = wl.Text;
                    newrowgx["FRkd"]        = (rkd.Text == "1") ? true : false;
                    newrowgx["FICMOBillNo"] = comboBox1.Text;
                    newrowgx["FBatchNo"]    = label6.Text;
                    newrowgx["FXh"]         = zxh.Text;
                    newrowgx["Fjh"]         = i + 1; //  卷号
                    newrowgx["FDs"]         = j + 1; //刀数
                    ds.Tables["tgx"].Rows.Add(newrowgx);
                    //  newrow["fyctm"] = dataGridView1.Rows[0].Cells["tm"].Value.ToString();
                    // newrow["fsycd"] =     (decimal.Parse(dataGridView1.Rows[0].Cells["sycd1"].Value.ToString()) / int.Parse(js.Text.Trim())/int.Parse(qds.Text.Trim())).ToString(("#0.0000"));
                    // newrow["flx"] = true;
                    // newrow["fcptm"] = gctm.Text;
                }
            }

            gxjl.Update(ds.Tables["tgx"]);
            dtylgx.Update(ds.Tables["gxb"]);


            //打印标签
            for (int j = 0; j < int.Parse(qds.Text.Trim()); j++)
            {
                for (int i = 0; i < int.Parse(js.Text.Trim()); i++)
                {
                    string ptnr = label6.Text + "-" + zxh.Text + "-" + (j + 1).ToString() + "-" + (i + 1).ToString() + "(" + Globals.userid + ")" + "|" + tmhb.Split('|')[i] + "|" + label8.Text;
                    FPt    pt   = new FPt(ptnr, 1);
                }
            }

            conn.Close();


            try
            {
                yscl.Text = (decimal.Parse(yscl.Text.Trim()) + decimal.Parse(mcd.Text.Trim()) * int.Parse(js.Text.Trim()) * int.Parse(qds.Text.Trim())).ToString();
            }
            catch
            {
                yscl.Text = (decimal.Parse(mcd.Text.Trim()) * int.Parse(js.Text.Trim()) * int.Parse(qds.Text.Trim())).ToString();
            }
            clearjm();
            label14.Text = "";
            label5.Text  = "";
            zxh.Clear();
            qds.Clear();
            dataGridView1.Rows.Clear();
            if (!lgxl())
            {
                MessageBox.Show("料已用完");
            }
        }
Ejemplo n.º 4
0
        //保存
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (!Globals.CheckNumber(mcd.Text.ToString().Trim()))
            {
                MessageBox.Show("膜长度必须为数字");
                mcd.Text = null;
                return;
            }
            if (mkd.Text != "")
            {
                if (!Globals.CheckNumber(mkd.Text.ToString().Trim()))
                {
                    MessageBox.Show("膜宽度必须为数字");
                    mkd.Text = null;
                    return;
                }
            }

            if (dataGridView1.RowCount <= 1 | gctm.Text == "")
            {
                MessageBox.Show("信息不全不能保存");
                return;
            }
            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                if (dataGridView1.Rows[i].Cells["sycd1"].Value == null)
                {
                    MessageBox.Show("使用长度必须为数字");

                    return;
                }

                if (!Globals.CheckNumber(dataGridView1.Rows[i].Cells["sycd1"].Value.ToString().Trim()))
                {
                    MessageBox.Show("使用长度必须为数字");

                    return;
                }

                if (decimal.Parse(dataGridView1.Rows[i].Cells["sycd1"].Value.ToString().Trim()) > decimal.Parse(dataGridView1.Rows[i].Cells["kycd"].Value.ToString().Trim()))
                {
                    MessageBox.Show("使用长度不能超可用长度");
                    dataGridView1.Rows[i].Cells["sycd1"].Value           = null;
                    dataGridView1.Rows[i].Cells["sycd1"].Style.BackColor = Color.Red;
                    return;
                }
            }

            if (MessageBox.Show("是否需要保存", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;  //否就退出操作
            }
            try
            {
                ds.Tables["tgx"].Clear();
            }
            catch { }
            try
            {
                ds.Tables["gxb"].Clear();
            }
            catch { }
            //try
            //{
            //    conn.Open();
            //}
            //catch { }
            //DataSet ds = new DataSet();
            //修改tyl表的 FSylength=FSylength-sycd
            string         insertsql = "SELECT  FBarcode, FWork, FQty, FMcd, FMkd, FMhd, FJs, FBc, FJyy, FBz, FUnitID, FICMOID, FItemID, FJlr, FJlrq,FRkd, FSfrk, FSfyw, FICMOBillNo ,FBatchNo,fscjt FROM  Tgx where 1=2 ";
            SqlDataAdapter gxjl      = new SqlDataAdapter(insertsql, conn);

            gxjl.Fill(ds, "tgx");
            DataRow newrowgx = ds.Tables["tgx"].NewRow();

            newrowgx["FBarcode"] = gctm.Text.Trim();
            newrowgx["FWork"]    = "检品";
            if (mzl.Text != "")
            {
                newrowgx["fqty"] = mzl.Text.Trim();
            }
            if (mcd.Text != "")
            {
                newrowgx["fmcd"] = mcd.Text.Trim();
            }
            if (mkd.Text != "")
            {
                newrowgx["fmkd"] = mkd.Text.Trim();
            }
            if (mhd.Text != "")
            {
                newrowgx["FMhd"] = mhd.Text.Trim();
            }
            newrowgx["fbc"]         = bc.Text;
            newrowgx["FJyy"]        = jyy.Text;
            newrowgx["fbz"]         = bz.Text;
            newrowgx["FJlr"]        = jlr.Text;
            newrowgx["FJlrq"]       = jlrq.Text;
            newrowgx["Fscjt"]       = jtmc.Text;
            newrowgx["FItemID"]     = wl.Text;
            newrowgx["FRkd"]        = (rkd.Text == "1") ? true : false;
            newrowgx["FICMOBillNo"] = comboBox1.Text;
            newrowgx["FBatchNo"]    = label6.Text;

            ds.Tables["tgx"].Rows.Add(newrowgx);

            SqlCommandBuilder sb1 = new SqlCommandBuilder(gxjl);
            //gxjl.Update(ds.Tables["tgx"]);

            //插入数据到tycpgx  原料产品关系对照表   FYctm    FSycd   FCptm
            string sql = "select fyctm,fsycd,FCptm from Tylcpgx  where 1=2";

            SqlDataAdapter dtylgx = new SqlDataAdapter(sql, conn);

            dtylgx.Fill(ds, "gxb");
            //批量写入原料与产品关系表
            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                if (dataGridView1.Rows[i].Cells["kycd"].Value == null)
                {
                    MessageBox.Show("必须录入膜使用长度");
                    ds.Tables["gxb"].Clear();
                    return;
                }
                DataRow newrow = ds.Tables["gxb"].NewRow();
                newrow["fyctm"] = dataGridView1.Rows[i].Cells["tm"].Value.ToString();
                try
                {
                    if (dataGridView1.Rows[i].Cells["yw"].Value.ToString() == "是")
                    {
                        newrow["fsycd"] = dataGridView1.Rows[i].Cells["kycd"].Value.ToString();
                    }
                    else
                    {
                        newrow["fsycd"] = dataGridView1.Rows[i].Cells["sycd1"].Value.ToString();
                    }
                }
                catch { newrow["fsycd"] = dataGridView1.Rows[i].Cells["sycd1"].Value.ToString(); }
                newrow["fcptm"] = gctm.Text;
                ds.Tables["gxb"].Rows.Add(newrow);
            }
            SqlCommandBuilder sb = new SqlCommandBuilder(dtylgx);

            gxjl.Update(ds.Tables["tgx"]);
            dtylgx.Update(ds.Tables["gxb"]);
            conn.Close();
            string ptnr = "检品|" + label6.Text + "|" + label8.Text + "|" + gctm.Text + "|" + jtmc.Text + "|" + Globals.usernm + "|" + jlrq.Text + "|" + jyy.Text + "|" + bc.Text + "|" + mcd.Text + "|" + ngx.Text + "|" + wlkd.Text;
            FPt    pt   = new FPt(ptnr);

            try
            {
                yscl.Text = (decimal.Parse(yscl.Text.Trim()) + decimal.Parse(mcd.Text.Trim())).ToString();
            }
            catch {
                yscl.Text = (decimal.Parse(mcd.Text.Trim())).ToString();
            }
            clearjm();
            dataGridView1.Rows.Clear();
            if (!lgxl())
            {
                MessageBox.Show("领料失败");
            }
        }
Ejemplo n.º 5
0
        private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
        {
            dataGridView1.EndEdit();
            // comboBox1.Focus();
            try
            {
                decimal hjzl = 0;
                for (int i = 0; i < dataGridView1.SelectedCells.Count; i++)
                {
                    hjzl += decimal.Parse(dataGridView1.SelectedCells[i].Value.ToString());
                }
                label14.Text = hjzl.ToString();
            }
            catch { }

            try
            {
                if (comboBox1.Text.Trim() != "")
                {
                    if (dataGridView1.CurrentCell.ColumnIndex == 1)
                    {
                        if (!Globals.CheckNumber(dataGridView1.CurrentRow.Cells["zl"].Value.ToString().Trim()))
                        {
                            MessageBox.Show("请输入数字");
                            dataGridView1.CurrentRow.Cells["zl"].Value = null;
                            return;
                        }

                        else if (dataGridView1.CurrentRow.Cells["barcode"].Value == null)
                        {
                            dataGridView1.CurrentRow.Cells["barcode"].Value = comboBox1.SelectedValue.ToString().PadLeft(5, '0') + DateTime.Now.Year.ToString().Substring(2, 2) + Globals.get_tmlsh(conn).PadLeft(5, '0');

                            dataGridView1.CurrentRow.Cells["cd"].Value = decimal.Parse(Math.Floor(decimal.Parse(dataGridView1.CurrentRow.Cells["zl"].Value.ToString()) / decimal.Parse(bl.Text)).ToString()); //计算重量

                            dataGridView1.CurrentRow.Cells["wlmc"].Value = comboBox1.Text;
                        }
                        DataRow[] drArr = dt1.Select("fname = '" + comboBox2.Text + "'");
                        if (dataGridView1.CurrentRow.Cells["fck"].Value == null)
                        {
                            dataGridView1.CurrentRow.Cells["fck"].Value  = comboBox2.Text;
                            dataGridView1.CurrentRow.Cells["fcw"].Value  = comboBox3.Text;
                            dataGridView1.CurrentRow.Cells["cknm"].Value = drArr[0]["FItemID"].ToString();;
                            dataGridView1.CurrentRow.Cells["cwnm"].Value = comboBox3.SelectedValue;

                            dataGridView1.CurrentRow.Cells["frkrq"].Value = dateTimePicker1.Text;
                            dataGridView1.CurrentRow.Cells["fscrq"].Value = dateTimePicker2.Text;

                            dataGridView1.CurrentRow.Cells["gysmc"].Value = gys.Text;
                            dataGridView1.CurrentRow.Cells["gysid"].Value = FSupplyID.Text;
                            dataGridView1.CurrentRow.Cells["rkdh"].Value  = textBox1.Text;
                            dataGridView1.CurrentRow.Cells["Fhjph"].Value = label16.Text;
                            dataGridView1.CurrentRow.Cells["Fxh"].Value   = xh.Text.Trim();
                            dataGridView1.CurrentRow.Cells["wlnm"].Value  = comboBox1.SelectedValue;
                            dataGridView1.CurrentRow.Cells["fpc"].Value   = pici.Text;
                        }
                    }
                }
                else
                {
                    dataGridView1.CurrentCell = dataGridView1[1, dataGridView1.CurrentCell.RowIndex];
                    MessageBox.Show("先选择物料");
                }
            }
            catch {
            }
        }
Ejemplo n.º 6
0
        private void dataGridView1_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Enter & dataGridView1.CurrentCell.ColumnIndex == 1)//是否选择的是第6个单元格
                {
                    if (!Globals.CheckNumber(dataGridView1.CurrentRow.Cells["zl"].Value.ToString().Trim()))
                    {
                        MessageBox.Show("请输入数字");
                        dataGridView1.CurrentRow.Cells["zl"].Value = null;
                        return;
                    }

                    else if (dataGridView1.CurrentRow.Cells["barcode"].Value == null)
                    {
                        dataGridView1.CurrentRow.Cells["barcode"].Value = comboBox1.SelectedValue.ToString().PadLeft(5, '0') + DateTime.Now.Year.ToString().Substring(2, 2) + Globals.get_tmlsh(conn).PadLeft(5, '0');

                        //  dataGridView1.CurrentRow.Cells["cd"].Value = int.Parse(Math.Floor(decimal.Parse(dataGridView1.CurrentRow.Cells["zl"].Value.ToString()) / decimal.Parse(bl.Text) * 1000000).ToString());//计算重量

                        dataGridView1.CurrentRow.Cells["cd"].Value = decimal.Parse(Math.Floor(decimal.Parse(dataGridView1.CurrentRow.Cells["zl"].Value.ToString()) / decimal.Parse(bl.Text)).ToString());//计算重量

                        dataGridView1.CurrentRow.Cells["wlmc"].Value = comboBox1.Text;
                    }
                    DataRow[] drArr = dt1.Select("fname = '" + comboBox2.Text + "'");

                    if (dataGridView1.CurrentRow.Cells["fck"].Value == null)
                    {
                        dataGridView1.CurrentRow.Cells["fck"].Value   = comboBox2.Text;
                        dataGridView1.CurrentRow.Cells["fcw"].Value   = comboBox3.Text;
                        dataGridView1.CurrentRow.Cells["cknm"].Value  = drArr[0]["FItemID"].ToString();;
                        dataGridView1.CurrentRow.Cells["cwnm"].Value  = comboBox3.SelectedValue;
                        dataGridView1.CurrentRow.Cells["frkrq"].Value = dateTimePicker1.Text;
                        dataGridView1.CurrentRow.Cells["fscrq"].Value = dateTimePicker2.Text;

                        dataGridView1.CurrentRow.Cells["gysmc"].Value = gys.Text;
                        dataGridView1.CurrentRow.Cells["gysid"].Value = FSupplyID.Text;
                        dataGridView1.CurrentRow.Cells["rkdh"].Value  = textBox1.Text;
                        dataGridView1.CurrentRow.Cells["Fhjph"].Value = label16.Text;
                        dataGridView1.CurrentRow.Cells["Fxh"].Value   = xh.Text.Trim();
                        dataGridView1.CurrentRow.Cells["wlnm"].Value  = comboBox1.SelectedValue;
                        dataGridView1.CurrentRow.Cells["fpc"].Value   = pici.Text;
                    }
                }



                if (e.KeyCode == Keys.Enter & dataGridView1.CurrentCell.ColumnIndex == 2)//是否选择的是第6个单元格
                {
                    if (!Globals.CheckNumber(dataGridView1.CurrentRow.Cells["cd"].Value.ToString().Trim()))
                    {
                        MessageBox.Show("请输入数字");
                        dataGridView1.CurrentRow.Cells["cd"].Value = null;
                        return;
                    }
                }

                // dataGridView1.CurrentCell = dataGridView1[1, dataGridView1.CurrentCell.RowIndex];
            }
            catch {
                MessageBox.Show("请选择料号");
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            dataGridView1.EndEdit();
            if (!Globals.CheckNumber(mcd.Text.ToString().Trim()))
            {
                MessageBox.Show("膜长度必须为数字");
                mcd.Text = null;
                return;
            }
            if (mkd.Text != "")
            {
                if (!Globals.CheckNumber(mkd.Text.ToString().Trim()))
                {
                    MessageBox.Show("膜宽度必须为数字");
                    mkd.Text = null;
                    return;
                }
            }


            if (dataGridView1.RowCount <= 1 | gctm.Text == "")
            {
                MessageBox.Show("信息不全不能保存");
                return;
            }
            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                if (dataGridView1.Rows[i].Cells["sycd"].Value == null)
                {
                    MessageBox.Show("使用长度必须为数字");

                    return;
                }



                if (!Globals.CheckNumber(dataGridView1.Rows[i].Cells["sycd"].Value.ToString().Trim()))
                {
                    MessageBox.Show("使用长度必须为数字");

                    return;
                }

                if (decimal.Parse(dataGridView1.Rows[i].Cells["sycd"].Value.ToString().Trim()) > decimal.Parse(dataGridView1.Rows[i].Cells["mc"].Value.ToString().Trim()))
                {
                    MessageBox.Show("使用长度不能超过膜长度");
                    dataGridView1.Rows[i].Cells["sycd"].Value           = null;
                    dataGridView1.Rows[i].Cells["sycd"].Style.BackColor = Color.Red;
                    return;
                }
            }

            if (MessageBox.Show("是否需要保存", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;  //否就退出操作
            }
            try
            {
                ds.Tables["tgx"].Clear();
            }
            catch { }
            try
            {
                ds.Tables["gxb"].Clear();
            }
            catch { }
            //try
            //{
            //    conn.Open();
            //}
            //catch { }
            // DataSet ds = new DataSet();
            //修改tyl表的 FSylength=FSylength-sycd
            string         insertsql = "SELECT  FBarcode, FWork, FQty, FMcd, FMkd, FMhd, FJs, FBc, FJyy, FBz, FUnitID, FICMOID, FItemID, FJlr, FJlrq,FRkd, FSfrk, FSfyw, FICMOBillNo ,FBatchNo,fscjt FROM  Tgx where 1=2 ";
            SqlDataAdapter gxjl      = new SqlDataAdapter(insertsql, conn);

            gxjl.Fill(ds, "tgx");
            DataRow newrowgx = ds.Tables["tgx"].NewRow();

            newrowgx["FBarcode"] = gctm.Text.Trim();
            newrowgx["FWork"]    = "印刷";
            if (mzl.Text != "")
            {
                newrowgx["fqty"] = mzl.Text.Trim();
            }
            if (mcd.Text != "")
            {
                newrowgx["fmcd"] = mcd.Text.Trim();
            }
            if (mkd.Text != "")
            {
                newrowgx["fmkd"] = mkd.Text.Trim();
            }
            if (mhd.Text != "")
            {
                newrowgx["FMhd"] = mhd.Text.Trim();
            }
            newrowgx["fbc"]         = bc.Text;
            newrowgx["FJyy"]        = jyy.Text;
            newrowgx["fbz"]         = bz.Text;
            newrowgx["FJlr"]        = jlr.Text;
            newrowgx["FJlrq"]       = jlrq.Text;
            newrowgx["Fscjt"]       = comboBox3.Text;
            newrowgx["FItemID"]     = wl.Text;
            newrowgx["FRkd"]        = (rkd.Text == "1") ? true : false;
            newrowgx["FICMOBillNo"] = comboBox1.Text;
            newrowgx["FBatchNo"]    = label6.Text;
            ds.Tables["tgx"].Rows.Add(newrowgx);

            SqlCommandBuilder sb1 = new SqlCommandBuilder(gxjl);
            //gxjl.Update(ds.Tables["tgx"]);

            //插入数据到tycpgx  原料产品关系对照表   FYctm    FSycd   FCptm
            string sql = "select fyctm,fsycd,FCptm from Tylcpgx  where 1=2";

            SqlDataAdapter dtylgx = new SqlDataAdapter(sql, conn);

            dtylgx.Fill(ds, "gxb");
            //批量写入原料与产品关系表
            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                if (dataGridView1.Rows[i].Cells["sycd"].Value.ToString().Trim() == null)
                {
                    MessageBox.Show("必须录入膜使用长度");
                    ds.Tables["gxb"].Clear();
                    return;
                }
                DataRow newrow = ds.Tables["gxb"].NewRow();
                newrow["fyctm"] = dataGridView1.Rows[i].Cells["tm"].Value.ToString();
                try
                {
                    if (dataGridView1.Rows[i].Cells["wj"].Value.ToString() == "是")
                    {
                        newrow["fsycd"] = dataGridView1.Rows[i].Cells["mc"].Value.ToString().Trim();
                    }
                    else
                    {
                        newrow["fsycd"] = dataGridView1.Rows[i].Cells["sycd"].Value.ToString().Trim();
                    }
                }
                catch { newrow["fsycd"] = dataGridView1.Rows[i].Cells["sycd"].Value.ToString().Trim(); }
                newrow["fcptm"] = gctm.Text;
                ds.Tables["gxb"].Rows.Add(newrow);
            }
            SqlCommandBuilder sb = new SqlCommandBuilder(dtylgx);

            gxjl.Update(ds.Tables["tgx"]);
            dtylgx.Update(ds.Tables["gxb"]);
            string ptnr = "印刷|" + label6.Text + "|" + label8.Text + "|" + gctm.Text + "|" + comboBox3.Text + "|" + Globals.usernm + "|" + jlrq.Text + "|" + jyy.Text + "|" + bc.Text + "|" + mcd.Text + "|" + ngx.Text + "|" + wlkd.Text;
            FPt    pt   = new FPt(ptnr);

            conn.Close();
            try
            {
                yscl.Text = (decimal.Parse(yscl.Text.Trim()) + decimal.Parse(mcd.Text.Trim())).ToString();
            }
            catch
            {
                yscl.Text = (decimal.Parse(mcd.Text.Trim())).ToString();
            }
            string yltm = "";

            yltm = "(";
            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                yltm += "'" + dataGridView1.Rows[i].Cells["tm"].Value + "',";
            }
            yltm = yltm.Substring(0, yltm.Length - 1);
            yltm = yltm + ")";


            string tl = "select FLength-yycd  sycd,fname,FYltm,  fqty - yycd * ISNULL(fcoefficient , 1) syzl,Frkrq,gys,hjph,FBatchNo from V_TYl  where FLength-yycd>0  and FYltm in" + yltm;



            DataTable tld = sj.ds(tl, "tl", conn);
            FPt       pt1;

            for (int i = 0; i < tld.Rows.Count; i++)
            {
                string pttlnr = "";
                pttlnr = tld.Rows[i]["fname"].ToString() + "|" + tld.Rows[i]["FYltm"].ToString() + "|" + decimal.Parse(tld.Rows[i]["sycd"].ToString()).ToString("#0") + "|" + Math.Round(decimal.Parse(tld.Rows[i]["syzl"].ToString()), 2) + "|" + tld.Rows[i]["Frkrq"].ToString() + "|" + tld.Rows[i]["gys"].ToString() + "|" + tld.Rows[i]["hjph"].ToString() + "|" + tld.Rows[i]["FBatchNo"].ToString();
                pt1    = new FPt(pttlnr, 4);
            }

            clearjm();
            lyl();
        }
Ejemplo n.º 8
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                if (!Globals.CheckNumber(dataGridView1.Rows[i].Cells["使用长度"].Value.ToString()))
                {
                    MessageBox.Show("使用长度必须为数字");
                    return;
                }
            }
            if (mcd.Text != "")
            {
                if (!Globals.CheckNumber(mcd.Text.ToString().Trim()))
                {
                    MessageBox.Show("长度必须为数字");
                    mcd.Text = null;
                    return;
                }
            }
            if (mzl.Text != "")
            {
                if (!Globals.CheckNumber(mzl.Text.ToString().Trim()))
                {
                    MessageBox.Show("重量必须为数字");
                    mzl.Text = null;
                    return;
                }
            }

            string sql;

            try { conn.Open(); } catch { }
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                sql = "update Tylcpgx set FSycd='" + dataGridView1.Rows[i].Cells["使用长度"].Value.ToString() + "' where FYctm='" + dataGridView1.Rows[i].Cells["原料条码"].Value.ToString() + "' and FCptm='" + gctm.Text + "'";
                cmd = new SqlCommand(sql, conn);

                cmd.ExecuteNonQuery();
            }
            string nr = "";

            if (mcd.Text == "")
            {
                if (gctm.Text != "")
                {
                    nr = "fqty = '" + mzl.Text + "'";
                }
            }
            else if (mzl.Text == "")
            {
                nr = "fmcd='" + mcd.Text + "' ";
            }
            else
            {
                nr = " fmcd='" + mcd.Text + "' ,fqty='" + mzl.Text + "'";
            }

            sql = "update tgx set " + nr + " where FBarcode='" + gctm.Text + "'";
            cmd = new SqlCommand(sql, conn);

            cmd.ExecuteNonQuery();
        }
Ejemplo n.º 9
0
        private void dataGridView1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter & dataGridView1.CurrentCell.ColumnIndex == 0)//是否选择的是第一个单元格
            {
                //验证不通过
                try
                {
                    if (!yanzheng(dataGridView1.CurrentRow.Cells["tm"].Value.ToString(), dataGridView1.CurrentCell.RowIndex))
                    {
                        dataGridView1.CurrentRow.Cells["tm"].Value = "";
                        return;
                    }

                    // dataGridView1.CurrentCell
                    //扫描原料条码  在dt_ycl中 查询
                    if (dt_gxl.Rows.Count != 0)
                    {
                        try
                        {
                            DataRow[] drArr = dt_gxl.Select("条码 = '" + dataGridView1.CurrentCell.Value.ToString().Trim() + "'");

                            dataGridView1.CurrentRow.Cells["kycd"].Value  = drArr[0]["可用长度"]; //膜长
                            dataGridView1.CurrentRow.Cells["sycd1"].Value = drArr[0]["可用长度"]; //膜长
                            dataGridView1.CurrentCell = dataGridView1[4, dataGridView1.CurrentCell.RowIndex];
                            dataGridView1.CurrentRow.Cells["mk"].Value = drArr[0]["膜宽"];
                            dataGridView1.CurrentRow.Cells["mh"].Value = drArr[0]["膜厚"];


                            decimal cd = 0;
                            int     js = 0;
                            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
                            {
                                cd = cd + decimal.Parse(dataGridView1.Rows[i].Cells["sycd1"].Value.ToString().Trim());
                                //  dataGridView1.Rows[i].Cells["sycd"].Value
                                js = i + 1;
                            }

                            zxjs.Text = js.ToString();
                            mcd.Text  = cd.ToString();
                            if (gctm.Text == "")
                            {
                                gctm.Text = wl.Text.PadLeft(5, '0') + Globals.GetTimeStamp();
                            }
                            try
                            {
                                mkd.Text = dataGridView1.Rows[0].Cells["mk"].Value.ToString();
                                mhd.Text = dataGridView1.Rows[0].Cells["mh"].Value.ToString();
                            }
                            catch { }


                            if (gctm.Text == "")
                            {
                                gctm.Text = wl.Text.PadLeft(5, '0') + Globals.GetTimeStamp();
                            }
                            //dataGridView1.CurrentRow.Cells[""].Value = drArr[0][""];
                            //dataGridView1.CurrentRow.Cells[""].Value = drArr[0][""];
                            //dataGridView1.CurrentRow.Cells[""].Value = drArr[0][""];
                        }
                        catch
                        {
                            MessageBox.Show("错误的条码,请重新扫描");
                            dataGridView1.CurrentRow.Cells["tm"].Value = "";
                        }
                        return;
                    }
                    else
                    {
                        MessageBox.Show("请先做生产领料单");
                    }
                }
                catch {
                    MessageBox.Show("错误的条码");
                    return;
                }
            }
            if (e.KeyCode == Keys.Enter & dataGridView1.CurrentCell.ColumnIndex == 4)//是否选择的是第6个单元格
            {
                if (!Globals.CheckNumber(dataGridView1.CurrentRow.Cells["sycd1"].Value.ToString().Trim()))
                {
                    MessageBox.Show("请输入数字");
                    dataGridView1.CurrentRow.Cells["sycd1"].Value = null;
                    return;
                }
                if (decimal.Parse(dataGridView1.CurrentRow.Cells["sycd1"].Value.ToString().Trim()) > decimal.Parse(dataGridView1.CurrentRow.Cells["kycd"].Value.ToString().Trim()))
                {
                    MessageBox.Show("使用长度不能超过膜长度");
                    dataGridView1.CurrentRow.Cells["sycd1"].Value = null;
                    return;
                }
            }
        }