Exemple #1
0
        private void TxtFieldWidth_Validating(object sender, CancelEventArgs e)
        {
            if (!string.IsNullOrEmpty(_Tag.ToString()))
            {
                int TotalWidth = 0;
                int.TryParse(TxtFieldWidth.Text, out TotalWidth);

                if (CmbFieldType.Text == "String")
                {
                    if (TotalWidth < 8 || TotalWidth > 255)
                    {
                        MessageBox.Show("Total Width Should be between 8 to 255", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        e.Cancel = true;
                        TxtFieldWidth.SelectAll();
                        TxtFieldWidth.Focus();
                    }
                }
                else if (CmbFieldType.Text == "Number")
                {
                    if (TotalWidth < 1 || TotalWidth > 18)
                    {
                        MessageBox.Show("Total Width Should be between 1 to 18", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        e.Cancel = true;
                        TxtFieldWidth.SelectAll();
                        TxtFieldWidth.Focus();
                    }
                }
                else if (CmbFieldType.Text == "Yes/No")
                {
                    if (TotalWidth != 1)
                    {
                        MessageBox.Show("Total Width Should be between 1", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        e.Cancel = true;
                        TxtFieldWidth.SelectAll();
                        TxtFieldWidth.Focus();
                    }
                }
                else if (CmbFieldType.Text == "Memo")
                {
                    if (TotalWidth < 1 || TotalWidth > 199)
                    {
                        MessageBox.Show("Total Width Should be between 1 to 199", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        e.Cancel = true;
                        TxtFieldWidth.SelectAll();
                        TxtFieldWidth.Focus();
                    }
                }
                else if (CmbFieldType.Text == "List")
                {
                    if (TotalWidth < 8 || TotalWidth > 255)
                    {
                        MessageBox.Show("Total Width Should be between 8 to 255", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        e.Cancel = true;
                        TxtFieldWidth.SelectAll();
                        TxtFieldWidth.Focus();
                    }
                }
            }
        }
Exemple #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);
            }
        }