Beispiel #1
0
 private void CLend()
 {
     this.CLdeng       = 0;
     this.CLrl         = "";
     this.CLzlmb       = new Decimal(0);
     this.CLcheng      = -1;
     this.CLzlyc       = new Decimal(-1);
     this.CLzlmc       = new Decimal(0);
     this.CLzlpz       = new Decimal(0);
     this.CLerrTPcount = 0;
     this.CLokCount    = 0;
     this.CLallowKey   = false;
     for (int index = 0; index < this.dgvDH.RowCount * this.dgvDH.ColumnCount; ++index)
     {
         this.dgvDH.Rows[index / 8].Cells[index % 8].Style.BackColor = Color.LightGray;
     }
     this.CLtimer.Stop();
     this.TSsound.Stop();
     if (!this.plcCL.OpenDeng(0))
     {
         this.plcCL.OpenDeng(0);
     }
     this.lblTS.ForeColor = Color.DarkRed;
     this.staCL           = frmCL.enumSta.显示有料;
     this.showRow();
 }
Beispiel #2
0
 private void CLstart()
 {
     if (this.dgvData.CurrentRow.Index < 0)
     {
         this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\error.wav";
         this.TSsound.Play();
         frmError frmError = new frmError("当前称料行不存在!请再次查询!");
         int      num      = (int)frmError.ShowDialog((IWin32Window)this);
         frmError.Close();
     }
     else
     {
         //DBpf dbpf = new DBpf(Settings.Default.DBconn);
         //T_PFmain tPfmain = dbpf.T_PFmain.Where<T_PFmain>((Expression<Func<T_PFmain, bool>>)(a => a.danhao == this.txtLDH.Text)).SingleOrDefault<T_PFmain>();
         T_PFmain tPfmain = db.Queryable <T_PFmain>()
                            .Where(a => a.danhao == this.txtLDH.Text)
                            .First();
         if (tPfmain == null || tPfmain.sta != "已审核")
         {
             //dbpf.Dispose();
             this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\error.wav";
             this.TSsound.Play();
             frmError frmError = new frmError("料单未审核或不存在!请再次查询!");
             int      num      = (int)frmError.ShowDialog((IWin32Window)this);
             frmError.Close();
         }
         else
         {
             //T_PFdata tPfdata = dbpf.T_PFdata.Where<T_PFdata>((Expression<Func<T_PFdata, bool>>)(a => a.SN == (long)this.dgvData.CurrentRow.Cells[this.colSN.Name].Value)).SingleOrDefault<T_PFdata>();
             T_PFdata tPfdata = db.Queryable <T_PFdata>()
                                .Where(a => a.SN == (long)this.dgvData.CurrentRow.Cells[this.colSN.Name].Value)
                                .First();
             if (tPfdata == null || tPfdata.ranliao != this.dgvData.CurrentRow.Cells[this.colRL.Name].Value.ToString())
             {
                 //dbpf.Dispose();
                 this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\error.wav";
                 this.TSsound.Play();
                 frmError frmError = new frmError("料单数据发生了改变!请再次查询!");
                 int      num      = (int)frmError.ShowDialog((IWin32Window)this);
                 frmError.Close();
             }
             else
             {
                 Decimal num1 = new Decimal(0);
                 Decimal num2;
                 if (this.txtLDH.Text.StartsWith("LD") || this.txtLDH.Text.Length == 10 && this.txtLDH.Text.StartsWith("8"))
                 {
                     num2 = tPfdata.yongliang;
                     if (tPfdata.yongliangDW == "Kg" || tPfdata.yongliangDW == "L")
                     {
                         num2 *= new Decimal(1000);
                     }
                 }
                 else
                 {
                     num2 = tPfdata.JLyongliang;
                     if (tPfdata.JLyongliangDW == "Kg" || tPfdata.JLyongliangDW == "L")
                     {
                         num2 *= new Decimal(1000);
                     }
                 }
                 if (num2 != (Decimal)this.dgvData.CurrentRow.Cells[this.colYL.Name].Value)
                 {
                     //dbpf.Dispose();
                     this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\error.wav";
                     this.TSsound.Play();
                     frmError frmError = new frmError("料单数据发生了改变!请再次查询!");
                     int      num3     = (int)frmError.ShowDialog((IWin32Window)this);
                     frmError.Close();
                 }
                 else
                 {
                     //dbpf.Dispose();
                     if (this.dgvData.CurrentRow.Cells[this.colCL.Name].FormattedValue.ToString() != "" && Convert.ToDecimal(this.dgvData.CurrentRow.Cells[this.colCL.Name].FormattedValue.ToString()) > new Decimal(0))
                     {
                         this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\error.wav";
                         this.TSsound.Play();
                         this.lblTS.Visible = false;
                         frmTS        frmTs        = new frmTS(this.CLrl, this.CLcheng, this.CLdeng, "该染料已称过,再称一次吗!!!", "“确认”再称一次", "“清除”取消称料", Keys.Back);
                         DialogResult dialogResult = frmTs.ShowDialog((IWin32Window)this);
                         frmTs.Close();
                         this.lblTS.Visible = true;
                         if (dialogResult != DialogResult.OK)
                         {
                             return;
                         }
                     }
                     if (this.CLcheng < 0)
                     {
                         this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\error.wav";
                         this.TSsound.Play();
                         frmError frmError = new frmError("无法找到合适的称,请核对!");
                         int      num3     = (int)frmError.ShowDialog((IWin32Window)this);
                         frmError.Close();
                     }
                     else
                     {
                         if (!this.plcCL.OpenDeng(this.CLdeng))
                         {
                             this.plcCL.OpenDeng(this.CLdeng);
                         }
                         this.staCL         = frmCL.enumSta.称料正在;
                         this.CLerrTPcount  = 0;
                         this.CLokCount     = 0;
                         this.CLallowKey    = false;
                         this.lblTPerr.Text = "";
                         this.CLzero();
                     }
                 }
             }
         }
     }
 }
Beispiel #3
0
        private void this_KeyUp(object sender, KeyEventArgs e)
        {
            if (this.staCL == frmCL.enumSta.显示空白 || this.staCL == frmCL.enumSta.显示有料)
            {
                this.lblKeyS.Text += e.KeyValue.ToString("X2");
                Application.DoEvents();
                if (Settings.Default.paraKeyB == 18 && e.KeyCode == Keys.F1 || Settings.Default.paraKeyB == 16 && (e.KeyCode == Keys.OemPeriod || e.KeyCode == Keys.Decimal))
                {
                    this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\ding.wav";
                    this.TSsound.Play();
                    frmCLsch     frmClsch     = Settings.Default.paraKeyB != 18 ? new frmCLsch("“返回”退出", Keys.Escape) : new frmCLsch("“F2”退出", Keys.F2);
                    DialogResult dialogResult = frmClsch.ShowDialog((IWin32Window)this);
                    frmClsch.Close();
                    if (dialogResult == DialogResult.OK)
                    {
                        if (this.showLD(frmClsch.txtSch.Text))
                        {
                            this.staCL = frmCL.enumSta.显示有料;
                            this.dgvData.CurrentCell = this.dgvData.Rows[0].Cells[this.colRL.Name];
                            this.showRow();
                        }
                        else
                        {
                            this.staCL = frmCL.enumSta.显示空白;
                        }
                    }
                    this.lblKeyS.Text = "";
                }
                else if (e.KeyCode == Keys.Prior)
                {
                    this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\ding.wav";
                    this.TSsound.Play();
                    if (this.dgvData.CurrentCell != null)
                    {
                        int rowIndex = this.dgvData.CurrentCell.RowIndex;
                        if (rowIndex > 0)
                        {
                            this.dgvData.CurrentCell = this.dgvData.Rows[rowIndex - 1].Cells[this.colRL.Name];
                            this.showRow();
                        }
                    }
                    this.lblKeyS.Text = "";
                }
                else if (e.KeyCode == Keys.Next)
                {
                    this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\ding.wav";
                    this.TSsound.Play();
                    if (this.dgvData.CurrentCell != null)
                    {
                        int rowIndex = this.dgvData.CurrentCell.RowIndex;
                        if (rowIndex < this.dgvData.RowCount - 1)
                        {
                            this.dgvData.CurrentCell = this.dgvData.Rows[rowIndex + 1].Cells[this.colRL.Name];
                            this.showRow();
                        }
                    }
                    this.lblKeyS.Text = "";
                }
                else
                {
                    if (e.KeyCode != Keys.Return)
                    {
                        return;
                    }
                    this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\ding.wav";
                    this.TSsound.Play();
                    if (this.staCL == frmCL.enumSta.显示有料 && this.lblKeyS.Text.Length == 2)
                    {
                        this.CLstart();
                    }
                    this.lblKeyS.Text = "";
                }
            }
            else
            {
                if (this.staCL != frmCL.enumSta.称料正在 || !this.CLallowKey)
                {
                    return;
                }
                if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete)
                {
                    this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\ding.wav";
                    this.TSsound.Play();
                    this.CLtimer.Stop();
                    this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\ding.wav";
                    this.TSsound.Play();
                    this.lblTS.Visible = false;
                    frmTS        frmTs        = Settings.Default.paraKeyB != 18 ? new frmTS(this.CLrl, this.CLcheng, this.CLdeng, "确定取消称料吗!!!", "“确认”退出称料", "“返回”继续称料", Keys.Escape) : new frmTS(this.CLrl, this.CLcheng, this.CLdeng, "确定取消称料吗!!!", "“确认”退出称料", "“ F2 ”继续称料", Keys.F2);
                    DialogResult dialogResult = frmTs.ShowDialog((IWin32Window)this);
                    frmTs.Close();
                    this.lblTS.Visible = true;
                    switch (dialogResult)
                    {
                    case DialogResult.OK:
                        if (this.cheng[this.CLcheng].showVal.Value > new Decimal(0))
                        {
                            this.CLzlmb = new Decimal(0);
                            this.CLzlpz = new Decimal(0);
                            this.CLsave();
                            this.dgvData.CurrentRow.Cells[this.colCL.Name].Value = (object)(this.dgvData.CurrentRow.Cells[this.colCL.Name].FormattedValue.ToString() == "" ? this.cheng[this.CLcheng].showVal.Value : (Decimal)this.dgvData.CurrentRow.Cells[this.colCL.Name].Value + this.cheng[this.CLcheng].showVal.Value);
                        }
                        this.CLend();
                        break;

                    case DialogResult.Cancel:
                        this.CLtimer.Start();
                        break;
                    }
                }
                else if (Settings.Default.paraKeyB == 18 && e.KeyCode == Keys.F2 || Settings.Default.paraKeyB == 16 && e.KeyCode == Keys.Prior)
                {
                    this.CLtimer.Enabled = false;
                    frmCLinputMC frmClinputMc = new frmCLinputMC((Decimal)this.dgvData.CurrentRow.Cells[this.colYL.Name].Value, "“确认”应用免称", "“返回”退出输入", Keys.Escape);
                    this.TSsound.SoundLocation = Application.StartupPath + "\\Sound\\ding.wav";
                    this.TSsound.Play();
                    if (frmClinputMc.ShowDialog((IWin32Window)this) == DialogResult.OK)
                    {
                        this.CLzlmc         = Convert.ToDecimal(frmClinputMc.txtZL.Text);
                        this.CLzlmb         = (Decimal)this.dgvData.CurrentRow.Cells[this.colYL.Name].Value - this.CLzlmc + this.CLzlpz;
                        this.lblCLmbzl.Text = this.CLzlmb.ToString("0.####克");
                        this.lblCLmcpz.Text = (this.CLzlmc == new Decimal(0) ? "" : "(免称:" + this.CLzlmc.ToString("0.####克") + ")") + (this.CLzlpz == new Decimal(0) ? "" : "(皮重:" + this.CLzlpz.ToString("0.####克") + ")");
                    }
                    frmClinputMc.Close();
                    this.CLtimer.Enabled = true;
                }
            }
        }
Beispiel #4
0
 private void this_Load(object sender, EventArgs e)
 {
     this.staCL = frmCL.enumSta.显示空白;
     this.emptyLD();
 }