Ejemplo n.º 1
0
        //This will update the value on MasterColumns and DataTables before performing Save or Edit
        private void SetColumnsValue()
        {
            DataRow row = null;

            if (FormState == FormStates.fsNew)
            {
                row = VMasterDataTable.NewRow();
            }
            else
            {
                row = VMasterDataTable.Rows.Find(IAppHandler.ConvertMaskValue(Parameters[0].Value));
                row.BeginEdit();
            }

            foreach (JkMasterColumn col in MasterColumns)
            {
                if (String.IsNullOrWhiteSpace(col.ControlName))
                {
                    if (!String.IsNullOrWhiteSpace(col.DefaultValue))
                    {
                        if ((col.Name == "CreatedById" || col.Name == "DateCreated") && FormState == FormStates.fsEdit)
                        {
                            col.Value = col.Value;
                        }
                        else
                        {
                            col.Value = IAppHandler.ConvertMaskValue(col.DefaultValue);
                        }
                    }
                }
                else
                {
                    col.Value = IAppHandler.GetControlsValue(Controls.Find(col.ControlName, true).First());
                }

                row[col.Name] = col.Value ?? DBNull.Value;
            }

            if (FormState == FormStates.fsNew)
            {
                VMasterDataTable.Rows.Add(row);
            }
            else
            {
                row.EndEdit();
            }
        }
Ejemplo n.º 2
0
        private void IMasterForm_ValidateSave()
        {
            ValidationFails = false;
            Object value = null;

            foreach (JkMasterColumn column in MasterColumns)
            {
                if (!String.IsNullOrWhiteSpace(column.ControlName) && column.Required)
                {
                    value = IAppHandler.GetControlsValue(Controls.Find(column.ControlName, true).First());

                    if (String.IsNullOrWhiteSpace(Convert.ToString(value)))
                    {
                        IMessageHandler.Inform(ISystemMessages.FillRequiredFieldMessage);
                        ValidationFails = true;
                        return;
                    }
                }
            }
        }