Ejemplo n.º 1
0
        private void txtPalletID_KeyDown(object sender, KeyEventArgs e)
        {
            string strPalletID = txtPalletID.Text.Trim();

            if (string.IsNullOrEmpty(strPalletID))
            {
                txtPalletID.Focus();
                return;
            }

            if (e.Handled)
            {
                txtPalletID.Focus();
                return;
            }

            if (e.KeyData == Keys.Enter)
            {
                try
                {
                    using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {
                        IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
                    }))
                    {
                        using (eSolutionDataContext db = new eSolutionDataContext())
                        {
                            string strPalletNo = txtPalletID.Text.Trim();
                            if (string.IsNullOrEmpty(strPalletNo))
                            {
                                return;
                            }

                            var qry = db.stp_POPalletInfo_Select("%", "%", strPalletNo);

                            if (qry != null)
                            {
                                dataTablePackingList   = Functions.LINQToDataTable(qry);
                                gcPalletize.DataSource = dataTablePackingList;

                                // Button Setting
                                btnCreatePallet.Enabled    = false;
                                btnUpdatePallet.Enabled    = true;
                                btnCancelPalletize.Enabled = true;

                                btnPrint.Enabled = true;
                            }
                            else
                            {
                                gcPalletize.DataSource = null;
                                XtraMessageBox.Show(string.Format("Could not found the Pallet No[{0}]!", strPalletNo), "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                // button setting
                                btnCreatePallet.Enabled    = true;
                                btnUpdatePallet.Enabled    = false;
                                btnCancelPalletize.Enabled = false;

                                btnPrint.Enabled = false;

                                txtPalletID.Focus();
                                return;
                            }
                        }
                        scope.Complete();
                    }
                }
                catch (Exception ex)
                {
                    string errMsg;
                    if (ex.InnerException == null)
                    {
                        errMsg = ex.Message.ToString();
                    }
                    else
                    {
                        errMsg = ex.InnerException.ToString();
                    }
                    XtraMessageBox.Show(string.Format("Could not found the Pallet No[{0}]!", strPalletID) + Environment.NewLine + errMsg, "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }