예제 #1
0
        bool ValidateForm()
        {
            if (cWorker.EditValue == null)
            {
                MessageBox.Show("Vui lòng chọn người phụ trách!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }


            if (string.IsNullOrEmpty(cKnifeList.Text))
            {
                MessageBox.Show("Vui lòng chọn loại dao!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            DataRowView selectData = (DataRowView)cKnifeList.GetSelectedDataRow();
            int         std        = TextUtils.ToInt(selectData.Row.ItemArray[2]);
            int         atc        = TextUtils.ToInt(selectData.Row.ItemArray[3]);
            int         currentSTD = TextUtils.ToInt(selectData.Row.ItemArray[4]);
            int         currentATC = TextUtils.ToInt(selectData.Row.ItemArray[5]);

            if (currentATC == atc)
            {
                if (MessageBox.Show("Mã dao này không thể tiếp tục sử dụng! \n Bạn có muốn hủy mã dao này?", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    // Huy dao
                    frmKnifeDisposed frm = new frmKnifeDisposed();
                    frm.knifeID = TextUtils.ToInt(cKnifeList.EditValue);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        knifeSharpeningModel = new KnifeSharpeningDetailsModel();
                        ClearFormData();
                        LoadData();
                    }
                }
                return(false);
            }

            /*if (currentModel.CurrentSTD == currentModel.STD)
             * {
             *      if (MessageBox.Show("Mã dao này cần được mài trước khi sử dụng! \n Bạn có muốn mài mã dao này ngay bây giờ?", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
             *      {
             *              // Mai dao
             *              frmKnifeSharpen frm = new frmKnifeSharpen();
             *              frm.knifeID = TextUtils.ToInt(cKnifeList.EditValue);
             *              if (frm.ShowDialog() == DialogResult.OK)
             *              {
             *
             *              }
             *      }
             *      return false;
             *
             * }*/
            return(true);
        }
예제 #2
0
        private void btnDisposeTool_Click(object sender, EventArgs e)
        {
            int id = TextUtils.ToInt(gvKnife.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            prevRow = gvKnife.GetSelectedRows()[0];
            frmKnifeDisposed frm = new frmKnifeDisposed();

            frm.knifeID = id;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                cbShowUnavailable_CheckedChanged(null, null);
                gvKnife.FocusedRowHandle = prevRow;
            }
        }
        bool ValidateForm()
        {
            /*if (cKnifeList.EditValue == null)
             * {
             *      MessageBox.Show("Vui lòng nhập mã dao!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
             *      return false;
             * }*/

            if (txbQuantity.Value == 0)
            {
                MessageBox.Show("Vui lòng nhập số lượng khác 0!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            if (cWorker.EditValue == null)
            {
                MessageBox.Show("Vui lòng chọn người phụ trách!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }


            if (string.IsNullOrEmpty(cKnifeList.Text))
            {
                MessageBox.Show("Vui lòng chọn loại dao!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            KnifeDetailListModel currentModel = (KnifeDetailListModel)KnifeDetailListBO.Instance.FindByPK(TextUtils.ToInt64(cKnifeList.EditValue));

            if (currentModel.CurrentATC == currentModel.ATC)
            {
                if (MessageBox.Show("Mã dao này không thể tiếp tục sử dụng! \n Bạn có muốn hủy mã dao này?", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    frmKnifeDisposed frm = new frmKnifeDisposed();
                    frm.knifeID = currentModel.ID;
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        knifeProcessedList = new KnifeProcessedListModel();
                        ClearFormData();
                        LoadData();
                    }
                }
                return(false);
            }

            if (currentModel.CurrentSTD == currentModel.STD)
            {
                if (MessageBox.Show("Mã dao này cần được mài trước khi sử dụng! \n Bạn có muốn mài mã dao này ngay bây giờ?", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    // Mai dao
                    frmKnifeSharpen frm = new frmKnifeSharpen();
                    frm.knifeID = TextUtils.ToInt(cKnifeList.EditValue);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        knifeProcessedList = new KnifeProcessedListModel();
                        ClearFormData();
                        LoadData();
                    }
                }
                return(false);
            }
            return(true);
        }