コード例 #1
0
        private void MyNumericTextBox_Validating(object sender, CancelEventArgs e)
        {
            MyNumericTextBox tb = (MyNumericTextBox)sender;

            if (string.IsNullOrEmpty((tb.Text)))
            {
                MessageBox.Show("Mandatory Field Cannot be Blank !", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tb.Focus();
                return;
            }
        }
コード例 #2
0
 protected MyNumericEditor(MyNumericTextBox template)
     : base(template)
 {
     this.InitializeTemplateControl();
 }
コード例 #3
0
        /// <summary>
        /// CreateControl
        /// </summary>
        /// <returns></returns>
        protected override Control CreateControl()
        {
            MyNumericTextBox c = this.TemplateControl.Clone() as MyNumericTextBox;

            return(c);
        }
コード例 #4
0
        private void FrmUDFMasterEntry_Load(object sender, EventArgs e)
        {
            mydt = _objUDF.GetByEntryModule(_UDFEntryModule);
            foreach (DataRow ro in mydt.Rows)
            {
                string    value = "";
                DataTable dt1   = ClsGlobal.UDFExistingDataMaster;
                ////---------------- load edit data bind ----------------
                //if (ClsGlobal.UDFExistingDataMaster.Rows.Count == 0 && !string.IsNullOrEmpty(_VoucherNo) && _VoucherNo!="0")
                //{
                //    ClsGlobal.FieldNameArrMaster.Clear();
                //    ClsGlobal.UDFDataArrMaster.Clear();
                //    DataTable mydatatable = _objUDF.GetUDF(_UDFType,_VoucherNo);
                //    foreach (DataRow dr1 in mydatatable.Rows)
                //    {
                //        ClsGlobal.FieldNameArrMaster.Add(dr1["UDFCode"].ToString());
                //        ClsGlobal.UDFDataArrMaster.Add(dr1["UDFData"].ToString());
                //    }

                //    DataRow dr = ClsGlobal.UDFExistingDataMaster.NewRow();

                //    dr[0] = 0;
                //    for (int i = 0; i < ClsGlobal.FieldNameArrMaster.Count(); i++)
                //    {
                //        if (i == 0)
                //        {
                //            dr[i + 1] = ClsGlobal.FieldNameArrMaster[i];
                //            dr[i + 2] = ClsGlobal.UDFDataArrMaster[i];
                //        }
                //        else
                //        {
                //            dr[i + 2 + (i - 1)] = ClsGlobal.FieldNameArrMaster[i];
                //            dr[i + 3 + (i - 1)] = ClsGlobal.UDFDataArrMaster[i];
                //        }
                //    }

                //    ClsGlobal.UDFExistingDataMaster.Rows.Add(dr);
                //    dt1 = ClsGlobal.UDFExistingDataMaster;
                //}
                ////---------- end load edit data bind ------------------

                if (dt1.Rows.Count > 0)
                {
                    string UDFCode = ro["UDFCode"].ToString();
                    value = dt1.Rows[0]["UDFData" + UDFCode].ToString();
                }

                counter += 1;
                locY    += 21 + 5;
                if (ro["FieldType"].ToString() != "Yes/No")
                {
                    Label myLabel = new Label();
                    myLabel.Location = new Point(10, locY);
                    myLabel.Size     = new System.Drawing.Size(200, 18);
                    myLabel.Text     = ro["FieldName"].ToString();
                    this.Controls.Add(myLabel);
                }

                if (ro["FieldType"].ToString() == "String")
                {
                    MyTextBox mytext = new MyTextBox();
                    mytext.Location  = new Point(210, locY);
                    mytext.Name      = "txt" + counter;
                    mytext.Size      = new System.Drawing.Size(250, 18);
                    mytext.TabIndex  = 0;
                    mytext.MaxLength = Convert.ToInt32(ro["FieldWidth"]);
                    mytext.Tag       = ro["FieldType"].ToString();
                    mytext.Text      = value;
                    if (ro["MandotaryOpt"].ToString() == "Y")
                    {
                        mytext.Validating += new System.ComponentModel.CancelEventHandler(this.MyTextBox_Validating);
                    }
                    this.Controls.Add(mytext);
                }

                if (ro["FieldType"].ToString() == "Memo")
                {
                    MyTextBox mytext = new MyTextBox();
                    mytext.Location  = new Point(210, locY);
                    mytext.Name      = "txt" + counter;
                    mytext.Size      = new System.Drawing.Size(280, 50);
                    mytext.TabIndex  = 0;
                    mytext.Text      = value;
                    mytext.MaxLength = Convert.ToInt32(ro["FieldWidth"]);
                    mytext.Tag       = ro["FieldType"].ToString();
                    mytext.Multiline = true;
                    if (ro["MandotaryOpt"].ToString() == "Y")
                    {
                        mytext.Validating += new System.ComponentModel.CancelEventHandler(this.MyTextBox_Validating);
                    }
                    this.Controls.Add(mytext);
                    locY += 29;
                }

                if (ro["FieldType"].ToString() == "Date")
                {
                    MyMaskedTextBox myDatetext = new MyMaskedTextBox();
                    myDatetext.Location = new Point(210, locY);
                    myDatetext.Name     = "txtdate" + counter;
                    myDatetext.Size     = new System.Drawing.Size(200, 18);
                    myDatetext.TabIndex = 0;
                    myDatetext.Text     = value;
                    if (ro["DateFormat"].ToString() == "YYYY")
                    {
                        myDatetext.Mask = "9999";
                    }
                    else if (ro["DateFormat"].ToString() == "MM/YYYY")
                    {
                        myDatetext.Mask = "99/9999";
                    }
                    if (ro["MandotaryOpt"].ToString() == "Y" && ro["DateFormat"].ToString() == "DD/MM/YYYY")
                    {
                        myDatetext.Validating += new System.ComponentModel.CancelEventHandler(this.MyDateTextBox_Validating);
                    }
                    this.Controls.Add(myDatetext);
                }

                if (ro["FieldType"].ToString() == "Number")
                {
                    MyNumericTextBox myNumtext = new MyNumericTextBox();
                    myNumtext.Location  = new Point(210, locY);
                    myNumtext.Name      = "txtNum" + counter;
                    myNumtext.Size      = new System.Drawing.Size(200, 18);
                    myNumtext.TabIndex  = 0;
                    myNumtext.Text      = value;
                    myNumtext.MaxLength = Convert.ToInt32(ro["FieldWidth"]);
                    myNumtext.Tag       = ro["Field_Decimal"].ToString();
                    myNumtext.Tag       = ro["FieldType"].ToString();
                    myNumtext.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
                    if (ro["MandotaryOpt"].ToString() == "Y")
                    {
                        myNumtext.Validating += new System.ComponentModel.CancelEventHandler(this.MyNumericTextBox_Validating);
                    }
                    myNumtext.Leave += new System.EventHandler(this.TextBox1_Leave);
                    this.Controls.Add(myNumtext);
                }

                if (ro["FieldType"].ToString() == "Yes/No")
                {
                    CheckBox myCheckBox = new CheckBox();
                    myCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
                    myCheckBox.Location   = new Point(10, locY);
                    myCheckBox.Name       = "chk" + counter;
                    myCheckBox.Size       = new System.Drawing.Size(220, 18);
                    myCheckBox.TabIndex   = 0;
                    myCheckBox.Text       = ro["FieldName"].ToString();
                    myCheckBox.UseVisualStyleBackColor = true;
                    myCheckBox.Checked = value == "Y" ? true : false;
                    //if (value == "Y")
                    //    myCheckBox.Checked = true;
                    //else
                    //    myCheckBox.Checked = false;

                    this.Controls.Add(myCheckBox);
                }

                if (ro["FieldType"].ToString() == "List")
                {
                    ComboBox myComboBox = new ComboBox();
                    myComboBox.DropDownStyle     = System.Windows.Forms.ComboBoxStyle.DropDownList;
                    myComboBox.FormattingEnabled = true;

                    _objUDF.GetSingle(ro["UDFCode"].ToString());
                    foreach (UDFDetailsEntryViewModel Udfdetail in _objUDF.ModelUDFDetailsEntry)
                    {
                        myComboBox.Items.Add(Udfdetail.ListName);
                    }

                    myComboBox.Location      = new Point(210, locY);
                    myComboBox.Name          = "cmb" + counter;
                    myComboBox.Size          = new System.Drawing.Size(350, 23);
                    myComboBox.TabIndex      = 0;
                    myComboBox.SelectedIndex = 0;
                    myComboBox.SelectedItem  = value;
                    this.Controls.Add(myComboBox);
                }
            }
        }
コード例 #5
0
        private void FrmUDFDetailEntry_Load(object sender, EventArgs e)
        {
            DataTable dt = _objUDF.GetByEntryModule(_UDFEntryModule);

            foreach (DataRow ro in dt.Rows)
            {
                string    value = "";
                DataRow[] dr    = ClsGlobal.UDFExistingDataTableDetails.Select("SNO ='" + _SNo + "'");
                if (dr.Count() > 0)
                {
                    value = dr[0]["UDFData" + ro["UDFCode"].ToString()].ToString();
                }
                counter += 1;
                locY    += 21 + 5;
                if (ro["FieldType"].ToString() != "Yes/No")
                {
                    Label myLabel = new Label();
                    myLabel.Location = new Point(10, locY);
                    myLabel.Text     = ro["FieldName"].ToString();
                    this.Controls.Add(myLabel);
                }

                if (ro["FieldType"].ToString() == "String")
                {
                    MyTextBox mytext = new MyTextBox();
                    mytext.Location = new Point(150, locY);
                    mytext.Name     = "txt" + counter;
                    mytext.Size     = new System.Drawing.Size(350, 18);
                    mytext.TabIndex = counter;
                    mytext.Text     = value;
                    this.Controls.Add(mytext);
                }

                if (ro["FieldType"].ToString() == "Memo")
                {
                    MyTextBox mytext = new MyTextBox();
                    mytext.Location  = new Point(150, locY);
                    mytext.Name      = "txt" + counter;
                    mytext.Size      = new System.Drawing.Size(300, 50);
                    mytext.TabIndex  = counter;
                    mytext.Text      = value;
                    mytext.Multiline = true;
                    this.Controls.Add(mytext);
                    locY += 29;
                }

                if (ro["FieldType"].ToString() == "Date")
                {
                    MyMaskedTextBox myDatetext = new MyMaskedTextBox();
                    myDatetext.Location = new Point(150, locY);
                    myDatetext.Name     = "txtdate" + counter;
                    myDatetext.Size     = new System.Drawing.Size(200, 18);
                    myDatetext.TabIndex = counter;
                    myDatetext.Text     = value;
                    this.Controls.Add(myDatetext);
                }

                if (ro["FieldType"].ToString() == "Number")
                {
                    MyNumericTextBox myNumtext = new MyNumericTextBox();
                    myNumtext.Location  = new Point(150, locY);
                    myNumtext.Name      = "txtNum" + counter;
                    myNumtext.Size      = new System.Drawing.Size(200, 18);
                    myNumtext.TabIndex  = counter;
                    myNumtext.Text      = value;
                    myNumtext.Tag       = ro["FieldDecimal"].ToString();
                    myNumtext.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
                    myNumtext.Leave    += new System.EventHandler(this.MyNumericTextBox_Leave);
                    this.Controls.Add(myNumtext);
                }

                if (ro["FieldType"].ToString() == "Yes/No")
                {
                    CheckBox myCheckBox = new CheckBox();
                    myCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
                    myCheckBox.Location   = new Point(10, locY);
                    myCheckBox.Name       = "chk" + counter;
                    myCheckBox.Size       = new System.Drawing.Size(154, 18);
                    myCheckBox.TabIndex   = counter;
                    myCheckBox.Text       = ro["FieldName"].ToString();
                    myCheckBox.UseVisualStyleBackColor = true;

                    if (value == "Y")
                    {
                        myCheckBox.Checked = true;
                    }
                    else
                    {
                        myCheckBox.Checked = false;
                    }

                    this.Controls.Add(myCheckBox);
                }

                if (ro["FieldType"].ToString() == "List")
                {
                    ComboBox myComboBox = new ComboBox();
                    myComboBox.DropDownStyle     = System.Windows.Forms.ComboBoxStyle.DropDownList;
                    myComboBox.FormattingEnabled = true;

                    _objUDF.GetSingle(ro["UDFCode"].ToString());
                    foreach (UDFDetailsEntryViewModel Udfdetail in _objUDF.ModelUDFDetailsEntry)
                    {
                        myComboBox.Items.Add(Udfdetail.ListName);
                    }

                    myComboBox.Location      = new Point(150, locY);
                    myComboBox.Name          = "cmb" + counter;
                    myComboBox.Size          = new System.Drawing.Size(350, 23);
                    myComboBox.TabIndex      = counter;
                    myComboBox.SelectedIndex = 0;

                    myComboBox.SelectedItem = value;

                    this.Controls.Add(myComboBox);
                }
            }
        }