コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                txtID.Text = txtID.Text.ToUpper();
                LFormControl obj;
                if (ValidData())
                {
                    switch (txtID.Text)
                    {
                    case "-1":
                        obj                 = new LFormControl();
                        obj.FormName        = Utility.sDbnull(txtFormName.Text);
                        obj.ControlName     = Utility.sDbnull(txtControlName.Text);
                        obj.PropertyName    = Utility.sDbnull(cboProperty.Text);
                        obj.ControlTypeName = Utility.sDbnull(cboType.Text);
                        obj.IsNew           = true;
                        obj.Save();

                        txtID.Text = Utility.sDbnull(LFormControl.CreateQuery().GetMax(LFormControl.Columns.ControlId));
                        obj        = LFormControl.FetchByID(Utility.Int32Dbnull(txtID.Text, -1));
                        if (obj != null)
                        {
                            DataRow newDr = dtList.NewRow();
                            Utility.FromObjectToDatarow(obj, ref newDr);
                            dtList.Rows.Add(newDr);
                        }
                        break;

                    default:
                        new Update(LFormControl.Schema.Name).Set(LFormControl.Columns.FormName).EqualTo(txtFormName.Text).
                        Set(LFormControl.Columns.ControlName).EqualTo(txtControlName.Text).
                        Set(LFormControl.Columns.PropertyName).EqualTo(cboProperty.Text).
                        Set(LFormControl.Columns.ControlTypeName).EqualTo(cboType.Text).
                        Where(LFormControl.Columns.ControlId).IsEqualTo(Utility.Int32Dbnull(txtID.Text)).
                        Execute();
                        obj = LFormControl.FetchByID(Utility.Int32Dbnull(txtID.Text, -1));
                        if (obj != null)
                        {
                            DataRow newDr = Utility.GetDataRow(dtList, LFormControl.Columns.ControlId, obj.ControlId);
                            Utility.FromObjectToDatarow(obj, ref newDr);
                            newDr.AcceptChanges();
                        }

                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
コード例 #2
0
        private void LoadData()
        {
            LFormControl obj = LFormControl.FetchByID(txtID.Text);

            if (obj != null)
            {
                txtFormName.Text    = Utility.sDbnull(obj.FormName);
                txtControlName.Text = Utility.sDbnull(obj.ControlName);
                cboProperty.Text    = Utility.sDbnull(obj.PropertyName);
                cboType.Text        = Utility.sDbnull(obj.ControlTypeName);
            }
        }