private bool checkValid(PayVouchersModel dModel)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("Xin hãy điền tên.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }
            else
            {
                DataTable dt;
                if (dModel.ID > 0)
                {
                    dt = TextUtils.Select("select Name from PayVouchers with(nolock) where upper(Replace(Name,' ','')) = '"
                                          + txtName.Text.Trim().ToUpper() + "' and ID <> " + dModel.ID);
                }
                else
                {
                    dt = TextUtils.Select("select Name from PayVouchers with(nolock) where upper(Replace(Name,' ','')) = '"
                                          + txtName.Text.Trim().ToUpper() + "'");
                }
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        MessageBox.Show("Tên này đã tồn tại!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return(false);
                    }
                }
            }

            return(true);
        }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (!grvData.IsDataRow(grvData.FocusedRowHandle))
            {
                return;
            }
            SetInterface(true);
            _isAdd     = false;
            _rownIndex = grvData.FocusedRowHandle;

            int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
            PayVouchersModel dModel = (PayVouchersModel)PayVouchersBO.Instance.FindByPK(ID);

            txtName.Text = dModel.Name;
        }
Exemple #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                PayVouchersModel dModel;
                if (_isAdd)
                {
                    dModel = new PayVouchersModel();
                }
                else
                {
                    int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                    dModel = (PayVouchersModel)PayVouchersBO.Instance.FindByPK(ID);
                }
                if (!checkValid(dModel))
                {
                    return;
                }

                dModel.Name = txtName.Text.Trim();
                dModel.Type = cboType.SelectedIndex;

                if (_isAdd)
                {
                    pt.Insert(dModel);
                }
                else
                {
                    pt.Update(dModel);
                }
                pt.CommitTransaction();
                loadData();
                SetInterface(false);
                ClearInterface();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
Exemple #4
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (!grvData.IsDataRow(grvData.FocusedRowHandle))
            {
                return;
            }
            SetInterface(true);
            _isAdd     = false;
            _rownIndex = grvData.FocusedRowHandle;

            int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
            PayVouchersModel dModel = (PayVouchersModel)PayVouchersBO.Instance.FindByPK(ID);

            txtName.Text = dModel.Name;
            //txtCode.Text = dModel.Code;
            //txtDescription.Text = dModel.Description;
            //cboCostType.SelectedIndex = dModel.Type;
            //chkIsFix.Checked = dModel.IsFix == 1 ? true : false;
            //cboDepartment.EditValue = dModel.DepartmentID;
        }
Exemple #5
0
 protected PayVouchersFacade(PayVouchersModel model) : base(model)
 {
 }