Esempio n. 1
0
 private void mzl_Click(object sender, EventArgs e)
 {
     if (gctm.Text == "")
     {
         gctm.Text = wl.Text.PadLeft(5, '0') + Globals.GetTimeStamp();
     }
 }
Esempio n. 2
0
        private void mcd_Click(object sender, EventArgs e)
        {
            //decimal cd = 0;
            //for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            //{
            //    cd = cd + decimal.Parse(dataGridView1.Rows[i].Cells["sycd1"].Value.ToString());
            //    //  dataGridView1.Rows[i].Cells["sycd"].Value



            //}
            //mcd.Text = cd.ToString();
            if (gctm.Text == "")
            {
                gctm.Text = wl.Text.PadLeft(5, '0') + Globals.GetTimeStamp();
            }
            // mkd.Text = dataGridView1.Rows[0].Cells["mk"].Value.ToString();
            // mhd.Text = dataGridView1.Rows[0].Cells["mh"].Value.ToString();
        }
Esempio 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("料已用完");
            }
        }
Esempio n. 4
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;
                }
            }
        }