Beispiel #1
0
        private void FrmUdfMaster_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && this.ActiveControl != GridList)
            {
                SendKeys.Send("{Tab}");
            }
            else if (e.KeyCode == Keys.Escape)
            {
                if (TxtListDescription.Visible == true)
                {
                    GridControlMode(false);
                    GridList.Focus();
                }
                else if (BtnCancel.Enabled == true)
                {
                    this.Tag = "";
                    BtnCancel.PerformClick();
                }
                else if (BtnCancel.Enabled == false)
                {
                    BtnExit.PerformClick();
                }

                DialogResult = DialogResult.Cancel;
                return;
            }
        }
Beispiel #2
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TxtDescription.Text.Trim()))
            {
                MessageBox.Show("Please Enter Description !", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtDescription.Focus();
                return;
            }

            if (string.IsNullOrEmpty(TxtPosition.Text.Trim()))
            {
                MessageBox.Show("Please Enter Schedule !", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtPosition.Focus();
                return;
            }

            if (string.IsNullOrEmpty(TxtFieldWidth.Text.Trim()))
            {
                MessageBox.Show("Please Enter Total Width !", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtFieldWidth.Focus();
                return;
            }

            if (CmbFieldType.Text == "List")
            {
                if (GridList.Rows.Count <= 0)
                {
                    MessageBox.Show("Please Enter Description !", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    GridList.Focus();
                    return;
                }
                if (GridList.Rows.Count == 1 && GridList.Rows[0].Cells["Description"].Value == null && GridList.Visible == true)
                {
                    MessageBox.Show("Please Enter Description !", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    GridList.Focus();
                    return;
                }
            }

            _objUdfMaster.Model.Tag     = _Tag;
            _objUdfMaster.Model.UDFCode = this._UDFCode;
            if ((_Tag == "EDIT" || _Tag == "DELETE") && _UDFCode == 0)
            {
                ClearFld();
                return;
            }

            _objUdfMaster.Model.EntryModule  = GridModule.Rows[Convert.ToInt32(GridModule.CurrentRow.Index)].Cells[0].Value.ToString();
            _objUdfMaster.Model.FieldName    = TxtDescription.Text;
            _objUdfMaster.Model.FieldType    = CmbFieldType.Text;
            _objUdfMaster.Model.FieldWidth   = TxtFieldWidth.Text;
            _objUdfMaster.Model.MandotaryOpt = ChkMandatoryOption.Checked == true ? "Y" : "N";
            if (TxtDateFormat.Visible == true)
            {
                _objUdfMaster.Model.DateFormat = TxtDateFormat.SelectedItem.ToString();
            }
            else
            {
                _objUdfMaster.Model.DateFormat = "YYYY";
            }
            _objUdfMaster.Model.FieldDecimal   = TxtFieldDecimal.Text;
            _objUdfMaster.Model.UdfPosition    = Convert.ToInt32(TxtPosition.Text);
            _objUdfMaster.Model.AllowDuplicate = ChkAllowDuplicate.Checked == true ? "Y" : "N";

            if (CmbFieldType.Text == "List")
            {
                UDFDetailsEntryViewModel UDFEntryDetails = null;
                foreach (DataGridViewRow ro in GridList.Rows)
                {
                    if (ro.Cells["Description"].Value != null)
                    {
                        UDFEntryDetails = new UDFDetailsEntryViewModel();
                        if (ro.Cells["Description"].Value != null)
                        {
                            UDFEntryDetails.ListName = ro.Cells["Description"].Value.ToString();
                        }
                        _objUdfMaster.ModelUDFDetailsEntry.Add(UDFEntryDetails);
                    }
                }
            }
            _objUdfMaster.Model.EnterBy = ClsGlobal.LoginUserCode;
            _objUdfMaster.Model.Gadget  = "Desktop";

            if (_Tag == "NEW")
            {
                if (ClsGlobal.ConfirmSave == 1)
                {
                    var dialogResult = MessageBox.Show("Are you sure want to Save New Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (dialogResult == DialogResult.Yes)
                    {
                        result = _objUdfMaster.SaveUdfMaster();
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    result = _objUdfMaster.SaveUdfMaster();
                }
            }
            else
            {
                result = _objUdfMaster.SaveUdfMaster();
            }

            if (!string.IsNullOrEmpty(result))
            {
                MessageBox.Show("Data submit successfully", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearFld();
            }
            else
            {
                MessageBox.Show("Error occured during data submit", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }