Example #1
0
        public static void ArsQryToPanel(ArsPanel pnl, ArsSQLQry qry)
        {
            foreach (Control control in pnl.Controls)
            {
                switch (control)
                {
                case ArsEdit _:
                    ArsEdit editControl = (control as ArsEdit);
                    switch (editControl.EditType)
                    {
                    case EnmEditType.String:
                        editControl.SetDataStr(qry.GetString(editControl.ArName));
                        break;

                    case EnmEditType.Numeric:
                        editControl.SetDataStr(qry.GetDouble(editControl.ArName).ToString());
                        break;

                    case EnmEditType.Decimal:
                        editControl.SetDataStr(qry.GetDouble(editControl.ArName).ToString());
                        break;

                    default:
                        editControl.SetDataStr(qry.GetString(editControl.ArName));
                        break;
                    }
                    break;

                case ArsMaskEdit _:
                    ArsMaskEdit maskEditControl = (control as ArsMaskEdit);
                    switch (maskEditControl.EditType)
                    {
                    case EnmMaskEditType.Phone:
                        maskEditControl.SetDataStr(qry.GetString(maskEditControl.ArName));
                        break;

                    default:
                        maskEditControl.SetDataStr(qry.GetString(maskEditControl.ArName));
                        break;
                    }
                    break;

                case ArsDateTime _:
                    ArsDateTime dateControl = (control as ArsDateTime);
                    dateControl.SetDataStr(qry.GetString(dateControl.ArName));
                    break;

                case ArsComboBox _:
                    ArsComboBox comboControl = (control as ArsComboBox);
                    comboControl.SetString(qry.GetString(comboControl.ArName));
                    if (comboControl.Items.Count == 0)
                    {
                        comboControl.LoadString = qry.GetString(comboControl.ArName);
                    }
                    break;

                case ArsCheck _:
                    ArsCheck checkControl = (control as ArsCheck);

                    if (qry.GetString(checkControl.ArName) == checkControl.CheckedValue)
                    {
                        checkControl.Checked = true;
                    }
                    else
                    {
                        checkControl.Checked = false;
                    }

                    if (!checkControl.Checked && qry.GetString(checkControl.ArName) == "True")
                    {
                        checkControl.Checked = true;
                    }

                    break;
                }
            }
        }
Example #2
0
        public static void ArsPanelToQry(ArsPanel pnl, ArsSQLQry qry)
        {
            foreach (Control control in pnl.Controls)
            {
                switch (control)
                {
                case ArsEdit _:
                    ArsEdit editControl = (control as ArsEdit);
                    if (editControl.ArName == "REC_ID")
                    {
                        continue;
                    }
                    switch (editControl.EditType)
                    {
                    case EnmEditType.String:
                        qry.SetString(editControl.ArName, editControl.GetDataStr());
                        break;

                    case EnmEditType.Numeric:
                        qry.SetInt(editControl.ArName, Convert.ToInt32(editControl.GetDataStr()));
                        break;

                    case EnmEditType.Decimal:
                        qry.SetDouble(editControl.ArName, Convert.ToDouble(editControl.GetDataStr()));
                        break;

                    default:
                        qry.SetString(editControl.ArName, editControl.GetDataStr());
                        break;
                    }
                    break;

                case ArsMaskEdit _:
                    ArsMaskEdit maskEditControl = (control as ArsMaskEdit);
                    switch (maskEditControl.EditType)
                    {
                    case EnmMaskEditType.Phone:
                        qry.SetString(maskEditControl.ArName, maskEditControl.GetDataStr());
                        break;

                    default:
                        qry.SetString(maskEditControl.ArName, maskEditControl.GetDataStr());
                        break;
                    }
                    break;

                case ArsDateTime _:
                    ArsDateTime dateControl = (control as ArsDateTime);
                    if (dateControl.DateTimeType == EnmDateTimeType.Date)
                    {
                        qry.SetDate(dateControl.ArName, dateControl.GetDataStr());
                    }
                    else if (dateControl.DateTimeType == EnmDateTimeType.Time)
                    {
                        qry.SetString(dateControl.ArName, dateControl.GetDataStr());
                    }
                    break;

                case ArsComboBox _:
                    ArsComboBox comboControl = (control as ArsComboBox);
                    qry.SetString(comboControl.ArName, comboControl.GetString());
                    break;

                case ArsCheck _:
                    ArsCheck checkControl = (control as ArsCheck);
                    if (checkControl.Checked)
                    {
                        qry.SetString(checkControl.ArName, checkControl.CheckedValue);
                    }
                    else
                    {
                        qry.SetString(checkControl.ArName, checkControl.UnCheckedValue);
                    }
                    break;
                }
            }
        }