Exemplo n.º 1
0
        /// <summary>
        /// F12 is Save
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (txtOrderNo.Text.Trim() == "")
            {
                MessageBox.Show("Bạn chưa nhập Order", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (TextUtils.ToInt(txtQty.Text.Trim()) == 0)
            {
                MessageBox.Show("Bạn chưa nhập Số lượng", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtLAP.Text.Trim() == "")
            {
                MessageBox.Show("Bạn chưa nhập TESTTA LAP", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtWorkerName.Text.Trim() == "")
            {
                MessageBox.Show("Bạn chưa nhập Người gia công", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtMeasureName.Text.Trim() == "")
            {
                MessageBox.Show("Bạn chưa nhập Người đo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtLeader.Text.Trim() == "")
            {
                MessageBox.Show("Bạn chưa nhập Leader", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // hiện thị messagebox về việc lưu dữ liệu
            DialogResult rs = MessageBox.Show("Bạn muốn lưu dữ liệu?", "Lưu dữ liệu", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (rs == DialogResult.Cancel)
            {
                return;
            }
            // thực hiện lấy giá trị trên form
            for (int i = 0; i < _qty; i++)
            {
                TesttaModel tModel = new TesttaModel();
                tModel.ID                = TextUtils.ToInt(grvData.Rows[i].Cells[colID.Name].Value);
                tModel.Number            = TextUtils.ToInt(grvData.Rows[i].Cells[colNumber.Name].Value);
                tModel.ClockDial11       = TextUtils.ToDecimal(grvData.Rows[i].Cells[colClockDial11.Name].Value);
                tModel.ClockDial12       = TextUtils.ToDecimal(grvData.Rows[i].Cells[colClockDial12.Name].Value);
                tModel.VibrationForward1 = TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrationForward1.Name].Value);
                tModel.VibrationReverse1 = TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrationReverse1.Name].Value);
                tModel.CheckEye11        = TextUtils.ToString(grvData.Rows[i].Cells[colCheckEye11.Name].Value);
                tModel.CheckEye12        = TextUtils.ToString(grvData.Rows[i].Cells[colCheckEye12.Name].Value);
                tModel.Result1           = TextUtils.ToString(grvData.Rows[i].Cells[colResult1.Name].Value);
                tModel.Vibrate11         = TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrate11.Name].Value);
                tModel.Vibrate12         = TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrate12.Name].Value);
                tModel.Vibrate13         = TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrate13.Name].Value);
                tModel.ClockDial21       = TextUtils.ToDecimal(grvData.Rows[i].Cells[colClockDial21.Name].Value);
                tModel.ClockDial22       = TextUtils.ToDecimal(grvData.Rows[i].Cells[colClockDial22.Name].Value);
                tModel.VibrationForward2 = TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrationForward2.Name].Value);
                tModel.VibrationReverse2 = TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrationReverse2.Name].Value);
                tModel.CheckEye21        = TextUtils.ToString(grvData.Rows[i].Cells[colCheckEye21.Name].Value);
                tModel.CheckEye22        = TextUtils.ToString(grvData.Rows[i].Cells[colCheckEye22.Name].Value);
                tModel.Result2           = TextUtils.ToString(grvData.Rows[i].Cells[colResult2.Name].Value);
                tModel.Vibrate21         = TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrate21.Name].Value);
                tModel.Vibrate22         = TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrate22.Name].Value);
                tModel.Vibrate23         = TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrate23.Name].Value);
                tModel.OrderCode         = txtOrderNo.Text.Trim();
                tModel.DateWork          = dteNgayGiaCong.Value.Date;
                tModel.WorkerName        = txtWorkerName.Text.Trim();
                tModel.MeasureName       = txtMeasureName.Text.Trim();
                tModel.Leader            = txtLeader.Text.Trim();

                // nếu ID = 0 thì thực hiện insert dữ liệu lên Database
                if (tModel.ID == 0)
                {
                    TesttaBO.Instance.Insert(tModel);
                }
                // ID khác 0 thực hiện update dữ liệu lên DataBase
                else
                {
                    TesttaBO.Instance.Update(tModel);
                }
            }

            txtOrderNo.Text = "";
            LoadData();
            //MessageBox.Show("Đã hoàn thành việc lưu dữ liệu", "Hoàn thành", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 2
0
 protected TesttaFacade(TesttaModel model) : base(model)
 {
 }
Exemplo n.º 3
0
        /// <summary>
        /// F12 is Save
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult rs = MessageBox.Show("Bạn muốn lưu dữ liệu?", "Lưu dữ liệu", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (rs == DialogResult.Cancel)
            {
                return;
            }
            for (int i = 0; i < Qty; i++)
            {
                TesttaModel tModel = new TesttaModel();
                tModel.ID                = TextUtils.ToInt(grvData.GetRowCellValue(i, colID));
                tModel.Number            = TextUtils.ToInt(grvData.GetRowCellValue(i, colNumber));
                tModel.ClockDial11       = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colClockDial11));
                tModel.ClockDial12       = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colClockDial12));
                tModel.VibrationForward1 = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVibrationMax1));
                tModel.VibrationReverse1 = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVibrationMin1));
                tModel.CheckEye11        = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colCheckEye11));
                tModel.CheckEye12        = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colCheckEye12));
                tModel.Result1           = TextUtils.ToString(grvData.GetRowCellValue(i, colResult1));
                tModel.Vibrate11         = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVibrate11));
                tModel.Vibrate12         = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVibrate12));
                tModel.Vibrate13         = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVibrate13));
                tModel.ClockDial21       = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colClockDial21));
                tModel.ClockDial22       = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colClockDial22));
                tModel.VibrationForward2 = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVibrationMax1));
                tModel.VibrationReverse2 = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVibrationMin1));
                tModel.CheckEye21        = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colCheckEye21));
                tModel.CheckEye22        = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colCheckEye22));
                tModel.Result2           = TextUtils.ToString(grvData.GetRowCellValue(i, colResult2));
                tModel.Vibrate21         = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVibrate21));
                tModel.Vibrate22         = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVibrate22));
                tModel.Vibrate23         = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVibrate23));
                tModel.OrderCode         = txtOrderNo.Text;
                tModel.DateWork          = dateTimePicker1.Value.Date;
                tModel.WorkerName        = txtWorkerName.Text;
                tModel.MeasureName       = txtName.Text;
                tModel.Leader            = txtLeader.Text;
                if (txtWorkerName.Text.Trim() == "" || txtName.Text.Trim() == "" || txtLeader.Text.Trim() == "")
                {
                    if (txtWorkerName.Text.Trim() == "")
                    {
                        MessageBox.Show("chưa nhập tên người gia công", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (txtName.Text.Trim() == "")
                    {
                        MessageBox.Show("chưa nhập tên người đo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (txtLeader.Text.Trim() == "")
                    {
                        MessageBox.Show("chưa nhập tên Leader", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    if (tModel.ID == 0)
                    {
                        TesttaBO.Instance.Insert(tModel);
                    }
                    else
                    {
                        TesttaBO.Instance.Update(tModel);
                    }
                }
            }
            MessageBox.Show("Đã hoàn thành việc lưu dữ liệu", "Hoàn thành", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }