Beispiel #1
0
        private void txt_Product_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.txt_DiskDetail.Text       = string.Empty;
                this.tabControl1.SelectedIndex = 0;
                CheckMain         cm  = new CheckMain();
                CheckDetailRecord cdr = new CheckDetailRecord();
                cm.Kw      = this.txt_Loc.Text;
                cm.Pnno    = this.txt_Product.Text.Substring(2, 10);
                cm.Sl      = 1;
                cm.Status  = 1;
                cm.Cpqufen = string.Empty;

                cdr.Sn       = txt_Product.Text;
                cdr.Scantime = System.DateTime.Now;
                cdr.Xxjh     = string.Empty;
                cdr.Tph      = string.Empty;
                cdr.Scaner   = Program.UserID;
                cdr.Kw       = this.txt_Loc.Text;
                string RollBack = string.Empty;
                if (this.ck_Rollback.Checked)
                {
                    RollBack = "RollBack";
                }
                string msg = cdr.SaveCheckData(cm, cdr, "SN", RollBack);
                if (msg != string.Empty)
                {
                    MessageBox.Show(msg);
                }
                else
                {
                    this.txt_DiskDetail.Text += "库位:" + this.txt_Loc.Text + "\r\n";
                    this.txt_DiskDetail.Text += "PN:" + this.txt_Product.Text.Substring(2, 10) + "\r\n";
                    this.txt_DiskDetail.Text += "SN:" + this.txt_Product.Text;
                }
                ClearInput();
                txt_Product.Focus();
                ck_Rollback.Checked = false;
            }
        }
        private void txt_Tray_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.txt_DiskDetail.Text = string.Empty;
                this.tabControl1.SelectedIndex = 0;
                CheckMain cm = new CheckMain();
                CheckDetailRecord cdr = new CheckDetailRecord();
                cm.Kw = this.txt_Loc.Text;
                cm.Pnno = string.Empty;
                cm.Sl = 1;
                cm.Status = 1;
                cm.Cpqufen = string.Empty;

                cdr.Tph = this.txt_Tray.Text;
                cdr.Scantime = System.DateTime.Now;
                cdr.Xxjh = string.Empty;
                cdr.Sn = string.Empty;
                cdr.Scaner = Program.UserID;
                cdr.Kw = this.txt_Loc.Text;
                string RollBack = string.Empty;
                if (this.ck_Rollback.Checked)
                {
                    RollBack = "RollBack";
                }
                string msg = cdr.SaveCheckData(cm, cdr, "TP", RollBack);
                if (msg != string.Empty)
                {
                    MessageBox.Show(msg);
                }
                else
                {
                    this.txt_DiskDetail.Text += "库位:" + this.txt_Loc.Text + "\r\n";
                    this.txt_DiskDetail.Text += "托盘:" + this.txt_Tray.Text + "\r\n";
                    this.txt_Loc.Enabled = false;
                    this.txt_Tray.Focus();
                }
                ClearInput();
                ck_Rollback.Checked = false;
            }
        }
        public string SaveCheckData(CheckMain ck,CheckDetailRecord cdr,string ScanType,string RollBack)
        {
            //string sqlInsert=string.Format(@"insert into ")
            try
            {
                if (RollBack == string.Empty)
                {
                    string selectForExist = string.Empty;
                    if (ScanType == "SN")
                    {
                        selectForExist = "select * from pandiandetail where sn='" + this.sn + "'";
                    }
                    else
                    {
                        selectForExist = "select * from pandiandetail where tph='" + this.tph + "'";
                    }
                    DataTable dtExist = SqliteDbFactory.GetSqliteDbOperator().SelectFromSql(selectForExist);
                    if (dtExist.Rows.Count > 0)
                    {
                        return "扫描纪录已存在,请不要重复扫描!";
                    }
                    else
                    {
                        if (ScanType == "SN")
                        {
                            string[] sql = new string[2];

                            string sqlInsertDetail = string.Format(@"insert into pandiandetail(sn,xxjh,tph,scaner,scantime,kw) values ('{0}','{1}','{2}','{3}',
            '{4}','{5}')", cdr.Sn, cdr.Xxjh, cdr.Tph, cdr.Scaner, cdr.Scantime, cdr.Kw);
                            sql[0] = sqlInsertDetail;

                            string sqlForSelectMain = "select * from pandianrecord where pnno='" + ck.Pnno + "'";
                            DataTable dtMain = SqliteDbFactory.GetSqliteDbOperator().SelectFromSql(sqlForSelectMain);
                            if (dtMain.Rows.Count == 0)
                            {
                                string sqlInsertMain = string.Format(@"insert into pandianrecord (kw,pnno,cpqufen,sl,stauts) values ('{0}','{1}','{2}',{3},{4})",
                                    ck.Kw, ck.Pnno, ck.Cpqufen, ck.Sl, ck.Status);
                                sql[1] = sqlInsertMain;
                            }
                            else
                            {
                                string sqlUpdateMain = string.Format(@"update pandianrecord set sl=sl+{0} where pnno='{1}'", ck.Sl, ck.Pnno);
                            }
                            SqliteDbFactory.GetSqliteDbOperator().BatchExecute(sql);
                        }
                        else
                        {
                            string sqlInsertDetail = string.Format(@"insert into pandiandetail(sn,xxjh,tph,scaner,scantime,kw) values ('{0}','{1}','{2}','{3}',
            '{4}','{5}')", cdr.Sn, cdr.Xxjh, cdr.Tph, cdr.Scaner, cdr.Scantime, cdr.Kw);
                            SqliteDbFactory.GetSqliteDbOperator().ExecuteNonQuery(sqlInsertDetail);
                        }
                    }
                    return string.Empty;
                }
                else
                {
                    string[] sql = new string[2];
                    string selectForExist = string.Empty;
                    if (ScanType == "SN")
                    {
                        selectForExist = "select * from pandiandetail where sn='" + this.sn + "'";
                    }
                    else
                    {
                        selectForExist = "select * from pandiandetail where tph='" + this.tph + "'";
                    }
                    DataTable dtExist = SqliteDbFactory.GetSqliteDbOperator().SelectFromSql(selectForExist);
                    if (dtExist.Rows.Count == 0)
                    {
                        return "此纪录尚未扫描,不能撤销扫描!";
                    }
                    else
                    {
                        string sqlForDelete = string.Empty;
                        if (ScanType == "SN")
                        {
                            sqlForDelete = string.Format(@"delete from pandiandetail where sn='{0}'", cdr.Sn);
                            string sqlMainRollBack = string.Format(@"update pandianrecord set sl=sl-{0} where pnno='{1}'", ck.Sl, ck.Pnno);
                            sql[0] = sqlForDelete;
                            sql[1] = sqlMainRollBack;
                            SqliteDbFactory.GetSqliteDbOperator().BatchExecute(sql);
                        }
                        else
                        {
                            sqlForDelete = string.Format(@"delete from pandiandetail where tph='{0}'", cdr.Tph);
                            SqliteDbFactory.GetSqliteDbOperator().ExecuteNonQuery(sqlForDelete);
                        }
                        return "撤销扫描成功!";
                    }
                }
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
Beispiel #4
0
        public string SaveCheckData(CheckMain ck, CheckDetailRecord cdr, string ScanType, string RollBack)
        {
            //string sqlInsert=string.Format(@"insert into ")
            try
            {
                if (RollBack == string.Empty)
                {
                    string selectForExist = string.Empty;
                    if (ScanType == "SN")
                    {
                        selectForExist = "select * from pandiandetail where sn='" + this.sn + "'";
                    }
                    else
                    {
                        selectForExist = "select * from pandiandetail where tph='" + this.tph + "'";
                    }
                    DataTable dtExist = SqliteDbFactory.GetSqliteDbOperator().SelectFromSql(selectForExist);
                    if (dtExist.Rows.Count > 0)
                    {
                        return("扫描纪录已存在,请不要重复扫描!");
                    }
                    else
                    {
                        if (ScanType == "SN")
                        {
                            string[] sql = new string[2];

                            string sqlInsertDetail = string.Format(@"insert into pandiandetail(sn,xxjh,tph,scaner,scantime,kuwei) values ('{0}','{1}','{2}','{3}',
'{4}','{5}')", cdr.Sn, cdr.Xxjh, cdr.Tph, cdr.Scaner, cdr.Scantime, cdr.Kw);
                            sql[0] = sqlInsertDetail;

                            string    sqlForSelectMain = "select * from pandianrecord where pnno='" + ck.Pnno + "'";
                            DataTable dtMain           = SqliteDbFactory.GetSqliteDbOperator().SelectFromSql(sqlForSelectMain);
                            if (dtMain.Rows.Count == 0)
                            {
                                string sqlInsertMain = string.Format(@"insert into pandianrecord (kw,pnno,cpqufen,sl,status) values ('{0}','{1}','{2}',{3},{4})",
                                                                     ck.Kw, ck.Pnno, ck.Cpqufen, ck.Sl, ck.Status);
                                sql[1] = sqlInsertMain;
                            }
                            else
                            {
                                string sqlUpdateMain = string.Format(@"update pandianrecord set sl=sl+{0} where pnno='{1}'", ck.Sl, ck.Pnno);
                            }
                            SqliteDbFactory.GetSqliteDbOperator().BatchExecute(sql);
                        }
                        else
                        {
                            string sqlInsertDetail = string.Format(@"insert into pandiandetail(sn,xxjh,tph,scaner,scantime,kuwei) values ('{0}','{1}','{2}','{3}',
'{4}','{5}')", cdr.Sn, cdr.Xxjh, cdr.Tph, cdr.Scaner, cdr.Scantime, cdr.Kw);
                            SqliteDbFactory.GetSqliteDbOperator().ExecuteNonQuery(sqlInsertDetail);
                        }
                    }
                    return(string.Empty);
                }
                else
                {
                    string[] sql            = new string[2];
                    string   selectForExist = string.Empty;
                    if (ScanType == "SN")
                    {
                        selectForExist = "select * from pandiandetail where sn='" + this.sn + "'";
                    }
                    else
                    {
                        selectForExist = "select * from pandiandetail where tph='" + this.tph + "'";
                    }
                    DataTable dtExist = SqliteDbFactory.GetSqliteDbOperator().SelectFromSql(selectForExist);
                    if (dtExist.Rows.Count == 0)
                    {
                        return("此纪录尚未扫描,不能撤销扫描!");
                    }
                    else
                    {
                        string sqlForDelete = string.Empty;
                        if (ScanType == "SN")
                        {
                            sqlForDelete = string.Format(@"delete from pandiandetail where sn='{0}'", cdr.Sn);
                            string sqlMainRollBack = string.Format(@"update pandianrecord set sl=sl-{0} where pnno='{1}'", ck.Sl, ck.Pnno);
                            sql[0] = sqlForDelete;
                            sql[1] = sqlMainRollBack;
                            SqliteDbFactory.GetSqliteDbOperator().BatchExecute(sql);
                        }
                        else
                        {
                            sqlForDelete = string.Format(@"delete from pandiandetail where tph='{0}'", cdr.Tph);
                            SqliteDbFactory.GetSqliteDbOperator().ExecuteNonQuery(sqlForDelete);
                        }
                        return("撤销扫描成功!");
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }