コード例 #1
0
        protected void SaveClick(object sender, CommandEventArgs e)
        {
            Protocol        Protocol = new Protocol();
            ProtocolVersion Version  = new ProtocolVersion();

            foreach (Control con in Form.Controls)
            {
                if (con is ICaisisInputControl)
                {
                    ICaisisInputControl cic = (ICaisisInputControl)con;
                    if (cic.Required && cic.Value.Trim() == "")
                    {
                        UserMessage.Text = "<span class=\"requiredField\">Fields named in red are required.</span>";
                        return;
                    }
                    string fieldName = cic.Field;
                    if (cic.Table == "Protocols")
                    {
                        Protocol[fieldName] = cic.Value;
                    }
                    else
                    {
                        Version[fieldName] = cic.Value;
                    }
                }
            }

            // need to set entered
            Protocol[Protocol.EnteredBy]   = EnteredBy.Text;
            Protocol[Protocol.EnteredTime] = EnteredTime.Text;

            if (e.CommandName.Equals("Lock"))
            {
                Protocol.Lock();
                Version.Lock();
            }
            else if (e.CommandName.Equals("Unlock"))
            {
                Protocol.Unlock();
                Version.Unlock();
            }
            else
            {
                Protocol.Save();
                if (!String.IsNullOrEmpty(Protocol[Protocol.ProtocolId].ToString()))
                {
                    Version[ProtocolVersion.ProtocolId] = Protocol[Protocol.ProtocolId];
                    Version.Save();
                }
            }

            RegisterUpdatePageScript();
        }