Exemplo n.º 1
0
        private void tbSerialNo_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    Cursor.Current = Cursors.WaitCursor;

                    var barcode = tbOrderNo.Text.Trim();
                    if (string.IsNullOrEmpty(barcode))
                    {
                        barcode = CeReader.Barcode.Scan();
                    }

                    if (string.IsNullOrEmpty(barcode))
                    {
                        GlobalMessageBox.ShowWarnning("กรุณาระบุเลขที่เอกสาร");
                        return;
                    }
                    else
                    {
                        if (barcode.Length > 10)
                        {
                            barcode = barcode.Substring(0, 10);
                        }

                        tbOrderNo.Text = barcode;
                        var order = ServiceHelper.MobileServices.OrderedSetGetByOrderNo(barcode);
                        if (order != null)
                        {
                            Cursor.Current = Cursors.Default;
                            new OrderedInfoForm(order).ShowDialog();
                            btnNew_Click(null, null);
                            return;
                        }

                        tbOrderNo.Text      = barcode;
                        tbOrderNo.ReadOnly  = true;
                        tbOrderNo.BackColor = Color.FromArgb(255, 255, 192);
                        btnSave.Enabled     = true;
                        grdForkLift.Enabled = true;
                    }
                }
                catch (Exception ex)
                { GlobalMessageBox.ShowError(ex.Message); }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                var forklifts = (List <ForkLift>)bindingSourceForklift.DataSource;

                var forklift = forklifts.Find(p => p.IsSelected);
                if (forklift != null)
                {
                    forklift.IsSelected = true;

                    var orderedSet = new OrderedSet();
                    orderedSet.OrderNo        = tbOrderNo.Text.Trim();
                    orderedSet.ForkliftNumber = forklift.ForkliftNumber;
                    orderedSet.DriverName     = forklift.DriverName;
                    orderedSet.CreatedBy      = string.Format("{0}:{1}", GlobalContext.UserCode, GlobalContext.UserName);
                    orderedSet.BranchCode     = GlobalContext.BranchCode;
                    orderedSet.ShippointCode  = GlobalContext.ShippointCode;
                    ServiceHelper.MobileServices.OrderedSetAdd(orderedSet);
                    Cursor.Current = Cursors.Default;
                    GlobalMessageBox.ShowInfomation("บันทึกการจ่ายใบจัด เรียบร้อย");
                    foreach (var item in forklifts)
                    {
                        item.IsSelected = false;
                    }
                    bindingSourceForklift.ResetBindings(false);
                    btnSave.Enabled = false;
                    btnNew_Click(null, null);
                }
                else
                {
                    Cursor.Current = Cursors.Default;
                    GlobalMessageBox.ShowWarnning("กรุณาเลือกรถ เพื่อใช้กับใบจัดนี้");
                }
            }
            catch (Exception ex)
            {
                GlobalMessageBox.ShowError(ex);
            }
            //finally
            //{
            //    Cursor.Current = Cursors.Default;
            //}
        }
Exemplo n.º 3
0
        private void tbOrderNoFinish_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    Cursor.Current = Cursors.WaitCursor;

                    var barcode = tbOrderNoFinish.Text.Trim();
                    if (string.IsNullOrEmpty(barcode))
                    {
                        barcode = CeReader.Barcode.Scan();
                    }
                    //if (!RF1DHelper.Scan(out barcode))
                    //    barcode = tbOrderNoFinish.Text.Trim();


                    if (string.IsNullOrEmpty(barcode))
                    {
                        GlobalMessageBox.ShowWarnning("กรุณาระบุเลขที่เอกสาร");
                        return;
                    }
                    else
                    {
                        if (barcode.Length > 10)
                        {
                            barcode = barcode.Substring(0, 10);
                        }

                        tbOrderNoFinish.Text = barcode;
                        var order = ServiceHelper.MobileServices.OrderedSetGetByOrderNo(barcode);
                        if (order != null)
                        {
                            if (order.FinishOn == null)
                            {
                                ServiceHelper.MobileServices.OrderedSetUpdate(barcode);
                                tbOrderNoFinish.Text = barcode;
                                GlobalMessageBox.ShowInfomation(string.Format("ปิดใบจัดเลขที่\n{0}\nเรียบร้อยแล้ว", barcode));
                                //tbOrderNoFinish.Text = string.Empty;
                                //tbOrderNoFinish.Focus();
                            }
                            else
                            {
                                new OrderedInfoForm(order).ShowDialog();
                            }
                            this.Close();
                        }
                        else
                        {
                            GlobalMessageBox.ShowWarnning("ไม่พบเลขที่เอกสารนี้ ในระบบ");
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobalMessageBox.ShowError(ex);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
        }