示例#1
0
 protected void Page_Command(Object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         // 01/16/2006 Paul.  Enable validator before validating page.
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
         if (Page.IsValid)
         {
             //string sCUSTOM_MODULE = "IFRAMES";
             //DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
             DbProviderFactory dbf = DbProviderFactories.GetFactory();
             using (IDbConnection con = dbf.CreateConnection())
             {
                 con.Open();
                 using (IDbTransaction trn = con.BeginTransaction())
                 {
                     try
                     {
                         SqlProcs.spIFRAMES_Update
                             (ref gID
                             , new DynamicControl(this, "NAME").Text
                             , new DynamicControl(this, "URL").Text
                             , new DynamicControl(this, "TYPE").SelectedValue
                             , new DynamicControl(this, "PLACEMENT").SelectedValue
                             , new DynamicControl(this, "STATUS").Checked
                             , trn
                             );
                         //SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                         trn.Commit();
                     }
                     catch (Exception ex)
                     {
                         trn.Rollback();
                         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                         ctlEditButtons.ErrorText = ex.Message;
                         return;
                     }
                 }
             }
             Response.Redirect("default.aspx");
         }
     }
     else if (e.CommandName == "Cancel")
     {
         if (Sql.IsEmptyGuid(gID))
         {
             Response.Redirect("default.aspx");
         }
         else
         {
             Response.Redirect("default.aspx");                     //Response.Redirect("view.aspx?ID=" + gID.ToString());
         }
     }
 }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            Guid   gPARENT_ID   = Sql.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            try
            {
                SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "PROJECT_TASK";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                SqlProcs.spPROJECT_TASKS_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "NAME").Text
                                    , new DynamicControl(this, "STATUS").SelectedValue
                                    , new DynamicControl(this, "DATE_DUE").DateValue
                                    , new DynamicControl(this, "DATE_START").DateValue
                                    , new DynamicControl(this, "PROJECT_ID").ID
                                    , new DynamicControl(this, "PRIORITY").SelectedValue
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , new DynamicControl(this, "ORDER_NUMBER").IntegerValue
                                    , new DynamicControl(this, "TASK_NUMBER").IntegerValue
                                    , new DynamicControl(this, "DEPENDS_ON_ID").ID
                                    , new DynamicControl(this, "MILESTONE_FLAG").Checked
                                    , new DynamicControl(this, "ESTIMATED_EFFORT").IntegerValue
                                    , new DynamicControl(this, "ACTUAL_EFFORT").IntegerValue
                                    , new DynamicControl(this, "UTILIZATION").IntegerValue
                                    , new DynamicControl(this, "PERCENT_COMPLETE").IntegerValue
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    // 11/17/2005 Paul.  SugarCRM does not redirect to the Project, even if the user changed it. Just do the same.
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
示例#3
0
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            // 08/21/2005 Paul.  Redirect to parent if that is where the note was originated.
            Guid   gPARENT_ID   = Sql.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            try
            {
                SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "BUGS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                //die("ERROR: uploaded file was too big: max filesize: {$sugar_config['upload_maxsize']}");
                                HtmlInputFile  fileATTACHMENT = FindControl("ATTACHMENT") as HtmlInputFile;
                                HttpPostedFile pstATTACHMENT  = null;
                                if (fileATTACHMENT != null)
                                {
                                    pstATTACHMENT = fileATTACHMENT.PostedFile;
                                }
                                if (pstATTACHMENT != null)
                                {
                                    long lFileSize      = pstATTACHMENT.ContentLength;
                                    long lUploadMaxSize = Sql.ToLong(Application["CONFIG.upload_maxsize"]);
                                    if ((lUploadMaxSize > 0) && (lFileSize > lUploadMaxSize))
                                    {
                                        throw(new Exception("ERROR: uploaded file was too big: max filesize: " + lUploadMaxSize.ToString()));
                                    }
                                }
                                SqlProcs.spBUGS_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "NAME").Text
                                    , new DynamicControl(this, "STATUS").SelectedValue
                                    , new DynamicControl(this, "PRIORITY").SelectedValue
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , new DynamicControl(this, "RESOLUTION").SelectedValue
                                    , new DynamicControl(this, "RELEASE").SelectedValue
                                    , new DynamicControl(this, "TYPE").SelectedValue
                                    , new DynamicControl(this, "FIXED_IN_RELEASE").SelectedValue
                                    , new DynamicControl(this, "WORK_LOG").Text
                                    , new DynamicControl(this, "SOURCE").Text
                                    , new DynamicControl(this, "PRODUCT_CATEGORY").SelectedValue
                                    , sMODULE
                                    , gPARENT_ID
                                    , trn
                                    );
                                if (pstATTACHMENT != null)
                                {
                                    // 08/20/2005 Paul.  File may not have been provided.
                                    if (pstATTACHMENT.FileName.Length > 0)
                                    {
                                        string sFILENAME       = Path.GetFileName(pstATTACHMENT.FileName);
                                        string sFILE_EXT       = Path.GetExtension(sFILENAME);
                                        string sFILE_MIME_TYPE = pstATTACHMENT.ContentType;

                                        Guid gAttachmentID = Guid.Empty;
                                        // 01/20/2006 Paul.  Must include in transaction
                                        SqlProcs.spBUG_ATTACHMENTS_Insert(ref gAttachmentID, gID, pstATTACHMENT.FileName, sFILENAME, sFILE_EXT, sFILE_MIME_TYPE, trn);
                                        LoadFile(gAttachmentID, pstATTACHMENT.InputStream, trn);
                                    }
                                }
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Save")
            {
                // 01/31/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".ConvertView", this);
                if (Page.IsValid)
                {
                    // 02/27/2006 Paul.  Fix condition on notes.  Enable only if text exists.
                    txtCONTACT_NOTES_NAME_DESCRIPTION.Text = txtCONTACT_NOTES_NAME_DESCRIPTION.Text.Trim();
                    reqCONTACT_NOTES_NAME.Enabled          = !Sql.IsEmptyString(txtCONTACT_NOTES_NAME_DESCRIPTION.Text);
                    reqCONTACT_NOTES_NAME.Validate();

                    txtACCOUNT_NOTES_NAME_DESCRIPTION.Text = txtACCOUNT_NOTES_NAME_DESCRIPTION.Text.Trim();
                    reqACCOUNT_NOTES_NAME.Enabled          = !Sql.IsEmptyString(txtACCOUNT_NOTES_NAME_DESCRIPTION.Text);
                    reqACCOUNT_NOTES_NAME.Validate();

                    txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text = txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text.Trim();
                    reqOPPORTUNITY_NOTES_NAME.Enabled          = !Sql.IsEmptyString(txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text);
                    reqOPPORTUNITY_NOTES_NAME.Validate();

                    // 01/31/2006 Paul.  SelectAccount is required if not creating an account but creating an opportunity.
                    reqSELECT_ACCOUNT_ID.Enabled = !chkCreateAccount.Checked && chkCreateOpportunity.Checked;
                    reqSELECT_ACCOUNT_ID.Validate();
                    reqACCOUNT_NAME.Enabled = chkCreateAccount.Checked;
                    reqACCOUNT_NAME.Validate();
                    reqOPPORTUNITY_NAME.Enabled = chkCreateOpportunity.Checked;
                    reqOPPORTUNITY_NAME.Validate();
                    reqOPPORTUNITY_AMOUNT.Enabled = chkCreateOpportunity.Checked;
                    reqOPPORTUNITY_AMOUNT.Validate();
                    reqAPPOINTMENT_NAME.Enabled = chkCreateAppointment.Checked;
                    reqAPPOINTMENT_NAME.Validate();
                    reqAPPOINTMENT_TIME_START.Enabled = chkCreateAppointment.Checked;
                    reqAPPOINTMENT_TIME_START.Validate();
                    if (chkCreateAppointment.Checked)
                    {
                        ctlAPPOINTMENT_DATE_START.Validate();
                    }
                }
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "LEADS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                Guid gCONTACT_ID     = Guid.Empty;
                                Guid gACCOUNT_ID     = Guid.Empty;
                                Guid gOPPORTUNITY_ID = Guid.Empty;
                                Guid gAPPOINTMENT_ID = Guid.Empty;

                                // 01/31/2006 Paul.  Create the contact first so that it can be used as the parent of the related records.
                                // We would normally create the related records second, but then it will become a pain to update the Contact ACCOUNT_ID field.
                                SqlProcs.spCONTACTS_New
                                    (ref gCONTACT_ID
                                    , new DynamicControl(this, "FIRST_NAME").Text
                                    , new DynamicControl(this, "LAST_NAME").Text
                                    , new DynamicControl(this, "PHONE_WORK").Text
                                    , new DynamicControl(this, "EMAIL1").Text
                                    , trn
                                    );

                                if (chkCreateAccount.Checked)
                                {
                                    SqlProcs.spACCOUNTS_Update
                                        (ref gACCOUNT_ID
                                        , Security.USER_ID
                                        , txtACCOUNT_NAME.Text
                                        , String.Empty
                                        , Guid.Empty
                                        , String.Empty
                                        , String.Empty
                                        , Sql.ToString(ViewState["PHONE_FAX"])
                                        , Sql.ToString(ViewState["BILLING_ADDRESS_STREET"])
                                        , Sql.ToString(ViewState["BILLING_ADDRESS_CITY"])
                                        , Sql.ToString(ViewState["BILLING_ADDRESS_STATE"])
                                        , Sql.ToString(ViewState["BILLING_ADDRESS_POSTALCODE"])
                                        , Sql.ToString(ViewState["BILLING_ADDRESS_COUNTRY"])
                                        , txtACCOUNT_DESCRIPTION.Text
                                        , String.Empty
                                        , txtACCOUNT_PHONE_WORK.Text
                                        , Sql.ToString(ViewState["PHONE_OTHER"])
                                        , Sql.ToString(ViewState["EMAIL1"])
                                        , Sql.ToString(ViewState["EMAIL2"])
                                        , txtACCOUNT_WEBSITE.Text
                                        , String.Empty
                                        , String.Empty
                                        , String.Empty
                                        , String.Empty
                                        , Sql.ToString(ViewState["SHIPPING_ADDRESS_STREET"])
                                        , Sql.ToString(ViewState["SHIPPING_ADDRESS_CITY"])
                                        , Sql.ToString(ViewState["SHIPPING_ADDRESS_STATE"])
                                        , Sql.ToString(ViewState["SHIPPING_ADDRESS_POSTALCODE"])
                                        , Sql.ToString(ViewState["SHIPPING_ADDRESS_COUNTRY"])
                                        , trn
                                        );

                                    if (!Sql.IsEmptyString(txtACCOUNT_NOTES_NAME.Text))
                                    {
                                        Guid gNOTE_ID = Guid.Empty;
                                        SqlProcs.spNOTES_Update
                                            (ref gNOTE_ID
                                            , txtACCOUNT_NOTES_NAME.Text
                                            , "Accounts"
                                            , gACCOUNT_ID
                                            , Guid.Empty
                                            , txtACCOUNT_NOTES_NAME_DESCRIPTION.Text
                                            , trn
                                            );
                                    }
                                }
                                else
                                {
                                    gACCOUNT_ID = Sql.ToGuid(txtSELECT_ACCOUNT_ID.Value);
                                }
                                if (chkCreateOpportunity.Checked)
                                {
                                    SqlProcs.spOPPORTUNITIES_Update
                                        (ref gOPPORTUNITY_ID
                                        , Security.USER_ID
                                        , gACCOUNT_ID
                                        , txtOPPORTUNITY_NAME.Text
                                        , String.Empty
                                        , new DynamicControl(this, "LEAD_SOURCE").SelectedValue
                                        , Sql.ToDecimal(txtOPPORTUNITY_AMOUNT.Text)
                                        , Guid.Empty
                                        , T10n.ToServerTime(ctlOPPORTUNITY_DATE_CLOSED.Value)
                                        , String.Empty
                                        , lstOPPORTUNITY_SALES_STAGE.SelectedValue
                                        , (float)0.0
                                        , txtOPPORTUNITY_DESCRIPTION.Text
                                        , String.Empty
                                        , Guid.Empty
                                        , trn
                                        );
                                    if (!Sql.IsEmptyString(txtOPPORTUNITY_NOTES_NAME.Text))
                                    {
                                        Guid gNOTE_ID = Guid.Empty;
                                        SqlProcs.spNOTES_Update
                                            (ref gNOTE_ID
                                            , txtOPPORTUNITY_NOTES_NAME.Text
                                            , "Opportunities"
                                            , gOPPORTUNITY_ID
                                            , Guid.Empty
                                            , txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text
                                            , trn
                                            );
                                    }
                                    // 03/04/2006 Paul.  Must be included in the transaction, otherwise entire operation will fail with a timeout message.
                                    SqlProcs.spOPPORTUNITIES_CONTACTS_Update(gOPPORTUNITY_ID, gCONTACT_ID, String.Empty, trn);
                                }
                                if (chkCreateAppointment.Checked)
                                {
                                    DateTime dtDATE_START = T10n.ToServerTime(Sql.ToDateTime(ctlAPPOINTMENT_DATE_START.DateText + " " + txtAPPOINTMENT_TIME_START.Text));
                                    if (radScheduleCall.Checked)
                                    {
                                        SqlProcs.spCALLS_Update
                                            (ref gAPPOINTMENT_ID
                                            , Security.USER_ID
                                            , txtAPPOINTMENT_NAME.Text
                                            , 1
                                            , 0
                                            , dtDATE_START
                                            , "Accounts"
                                            , Guid.Empty
                                            , "Planned"
                                            , "Outbound"
                                            , -1
                                            , txtAPPOINTMENT_DESCRIPTION.Text
                                            , gCONTACT_ID.ToString()                                                     // 01/31/2006 Paul.  This is were we relate this call to the contact.
                                            , trn
                                            );
                                    }
                                    else
                                    {
                                        SqlProcs.spMEETINGS_Update
                                            (ref gAPPOINTMENT_ID
                                            , Security.USER_ID
                                            , txtAPPOINTMENT_NAME.Text
                                            , String.Empty
                                            , 1
                                            , 0
                                            , dtDATE_START
                                            , "Planned"
                                            , "Accounts"
                                            , Guid.Empty
                                            , -1
                                            , txtAPPOINTMENT_DESCRIPTION.Text
                                            , gCONTACT_ID.ToString()                                                     // 01/31/2006 Paul.  This is were we relate this meeting to the contact.
                                            , trn
                                            );
                                    }
                                }
                                SqlProcs.spCONTACTS_ConvertLead
                                    (ref gCONTACT_ID
                                    , gID                                                                       // 01/31/2006 Paul.  Update the Lead with this contact.
                                    , Security.USER_ID
                                    , new DynamicControl(this, "SALUTATION").SelectedValue
                                    , new DynamicControl(this, "FIRST_NAME").Text
                                    , new DynamicControl(this, "LAST_NAME").Text
                                    , gACCOUNT_ID
                                    , new DynamicControl(this, "LEAD_SOURCE").SelectedValue
                                    , new DynamicControl(this, "TITLE").Text
                                    , new DynamicControl(this, "DEPARTMENT").Text
                                    , new DynamicControl(this, "DO_NOT_CALL").Checked
                                    , new DynamicControl(this, "PHONE_HOME").Text
                                    , new DynamicControl(this, "PHONE_MOBILE").Text
                                    , new DynamicControl(this, "PHONE_WORK").Text
                                    , new DynamicControl(this, "PHONE_OTHER").Text
                                    , new DynamicControl(this, "PHONE_FAX").Text
                                    , new DynamicControl(this, "EMAIL1").Text
                                    , new DynamicControl(this, "EMAIL2").Text
                                    , new DynamicControl(this, "EMAIL_OPT_OUT").Checked
                                    , new DynamicControl(this, "INVALID_EMAIL").Checked
                                    , new DynamicControl(this, "PRIMARY_ADDRESS_STREET").Text
                                    , new DynamicControl(this, "PRIMARY_ADDRESS_CITY").Text
                                    , new DynamicControl(this, "PRIMARY_ADDRESS_STATE").Text
                                    , new DynamicControl(this, "PRIMARY_ADDRESS_POSTALCODE").Text
                                    , new DynamicControl(this, "PRIMARY_ADDRESS_COUNTRY").Text
                                    , Sql.ToString(ViewState["ALT_ADDRESS_STREET"])
                                    , Sql.ToString(ViewState["ALT_ADDRESS_CITY"])
                                    , Sql.ToString(ViewState["ALT_ADDRESS_STATE"])
                                    , Sql.ToString(ViewState["ALT_ADDRESS_POSTALCODE"])
                                    , Sql.ToString(ViewState["ALT_ADDRESS_COUNTRY"])
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , gOPPORTUNITY_ID
                                    , txtOPPORTUNITY_NAME.Text
                                    , txtOPPORTUNITY_AMOUNT.Text
                                    , trn
                                    );
                                if (!Sql.IsEmptyString(txtCONTACT_NOTES_NAME.Text))
                                {
                                    Guid gNOTE_ID = Guid.Empty;
                                    SqlProcs.spNOTES_Update
                                        (ref gNOTE_ID
                                        , txtCONTACT_NOTES_NAME.Text
                                        , String.Empty
                                        , Guid.Empty
                                        , gCONTACT_ID
                                        , txtCONTACT_NOTES_NAME_DESCRIPTION.Text
                                        , trn
                                        );
                                }

                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
 protected void Page_Command(Object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         // 01/16/2006 Paul.  Enable validator before validating page.
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
         if (Page.IsValid)
         {
             string            sCUSTOM_MODULE = "CAMPAIGNS";
             DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
             DbProviderFactory dbf            = DbProviderFactories.GetFactory();
             using (IDbConnection con = dbf.CreateConnection())
             {
                 con.Open();
                 using (IDbTransaction trn = con.BeginTransaction())
                 {
                     try
                     {
                         // 04/24/2006 Paul.  Upgrade to SugarCRM 4.2 Schema.
                         SqlProcs.spCAMPAIGNS_Update
                             (ref gID
                             , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                             , new DynamicControl(this, "NAME").Text
                             , new DynamicControl(this, "REFER_URL").Text
                             , new DynamicControl(this, "TRACKER_TEXT").Text
                             , new DynamicControl(this, "START_DATE").DateValue
                             , new DynamicControl(this, "END_DATE").DateValue
                             , new DynamicControl(this, "STATUS").SelectedValue
                             , new DynamicControl(this, "BUDGET").DecimalValue
                             , new DynamicControl(this, "EXPECTED_COST").DecimalValue
                             , new DynamicControl(this, "ACTUAL_COST").DecimalValue
                             , new DynamicControl(this, "EXPECTED_REVENUE").DecimalValue
                             , new DynamicControl(this, "CAMPAIGN_TYPE").SelectedValue
                             , new DynamicControl(this, "OBJECTIVE").Text
                             , new DynamicControl(this, "CONTENT").Text
                             , new DynamicControl(this, "CURRENCY_ID").ID
                             , trn
                             );
                         SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                         trn.Commit();
                     }
                     catch (Exception ex)
                     {
                         trn.Rollback();
                         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                         ctlEditButtons.ErrorText = ex.Message;
                         return;
                     }
                 }
             }
             Response.Redirect("view.aspx?ID=" + gID.ToString());
         }
     }
     else if (e.CommandName == "Cancel")
     {
         if (Sql.IsEmptyGuid(gID))
         {
             Response.Redirect("default.aspx");
         }
         else
         {
             Response.Redirect("view.aspx?ID=" + gID.ToString());
         }
     }
 }
 protected void Page_Command(Object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         // 01/16/2006 Paul.  Enable validator before validating page.
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".ConvertView", this);
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".ConvertAddress", this);
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".ConvertDescription", this);
         if (Page.IsValid)
         {
             Guid              gLEAD_ID       = Guid.Empty;
             string            sCUSTOM_MODULE = "LEADS";
             DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
             DbProviderFactory dbf            = DbProviderFactories.GetFactory();
             using (IDbConnection con = dbf.CreateConnection())
             {
                 con.Open();
                 using (IDbTransaction trn = con.BeginTransaction())
                 {
                     try
                     {
                         // 04/24/2006 Paul.  Upgrade to SugarCRM 4.2 Schema.
                         SqlProcs.spLEADS_ConvertProspect
                             (ref gLEAD_ID
                             , gID                                                                       // 01/31/2006 Paul.  Update the Prospect with this lead.
                             , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                             , new DynamicControl(this, "SALUTATION").SelectedValue
                             , new DynamicControl(this, "FIRST_NAME").Text
                             , new DynamicControl(this, "LAST_NAME").Text
                             , new DynamicControl(this, "TITLE").Text
                             , new DynamicControl(this, "REFERED_BY").Text
                             , new DynamicControl(this, "LEAD_SOURCE").SelectedValue
                             , new DynamicControl(this, "LEAD_SOURCE_DESCRIPTION").Text
                             , new DynamicControl(this, "STATUS").SelectedValue
                             , new DynamicControl(this, "STATUS_DESCRIPTION").Text
                             , new DynamicControl(this, "DEPARTMENT").Text
                             , Guid.Empty                                      // 06/24/2005. REPORTS_TO_ID is not used in version 3.0.
                             , new DynamicControl(this, "DO_NOT_CALL").Checked
                             , new DynamicControl(this, "PHONE_HOME").Text
                             , new DynamicControl(this, "PHONE_MOBILE").Text
                             , new DynamicControl(this, "PHONE_WORK").Text
                             , new DynamicControl(this, "PHONE_OTHER").Text
                             , new DynamicControl(this, "PHONE_FAX").Text
                             , new DynamicControl(this, "EMAIL1").Text
                             , new DynamicControl(this, "EMAIL2").Text
                             , new DynamicControl(this, "EMAIL_OPT_OUT").Checked
                             , new DynamicControl(this, "INVALID_EMAIL").Checked
                             , new DynamicControl(this, "PRIMARY_ADDRESS_STREET").Text
                             , new DynamicControl(this, "PRIMARY_ADDRESS_CITY").Text
                             , new DynamicControl(this, "PRIMARY_ADDRESS_STATE").Text
                             , new DynamicControl(this, "PRIMARY_ADDRESS_POSTALCODE").Text
                             , new DynamicControl(this, "PRIMARY_ADDRESS_COUNTRY").Text
                             , new DynamicControl(this, "ALT_ADDRESS_STREET").Text
                             , new DynamicControl(this, "ALT_ADDRESS_CITY").Text
                             , new DynamicControl(this, "ALT_ADDRESS_STATE").Text
                             , new DynamicControl(this, "ALT_ADDRESS_POSTALCODE").Text
                             , new DynamicControl(this, "ALT_ADDRESS_COUNTRY").Text
                             , new DynamicControl(this, "DESCRIPTION").Text
                             , new DynamicControl(this, "ACCOUNT_NAME").Text
                             , new DynamicControl(this, "CAMPAIGN_ID").ID
                             , trn
                             );
                         SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                         trn.Commit();
                     }
                     catch (Exception ex)
                     {
                         trn.Rollback();
                         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                         ctlEditButtons.ErrorText = ex.Message;
                         return;
                     }
                 }
             }
             Response.Redirect("view.aspx?ID=" + gID.ToString());
         }
     }
     else if (e.CommandName == "Cancel")
     {
         if (Sql.IsEmptyGuid(gID))
         {
             Response.Redirect("default.aspx");
         }
         else
         {
             Response.Redirect("view.aspx?ID=" + gID.ToString());
         }
     }
 }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Save")
            {
                try
                {
                    // 01/16/2006 Paul.  Enable validator before validating page.
                    SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                    if (Page.IsValid)
                    {
                        DataTable         dtACLACCESS = null;
                        DbProviderFactory dbf         = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            con.Open();
                            string sSQL;
                            sSQL = "select MODULE_NAME          " + ControlChars.CrLf
                                   + "     , DISPLAY_NAME         " + ControlChars.CrLf
                                   + "     , ACLACCESS_ADMIN      " + ControlChars.CrLf
                                   + "     , ACLACCESS_ACCESS     " + ControlChars.CrLf
                                   + "     , ACLACCESS_VIEW       " + ControlChars.CrLf
                                   + "     , ACLACCESS_LIST       " + ControlChars.CrLf
                                   + "     , ACLACCESS_EDIT       " + ControlChars.CrLf
                                   + "     , ACLACCESS_DELETE     " + ControlChars.CrLf
                                   + "     , ACLACCESS_IMPORT     " + ControlChars.CrLf
                                   + "     , ACLACCESS_EXPORT     " + ControlChars.CrLf
                                   + "  from vwACL_ACCESS_ByModule" + ControlChars.CrLf
                                   + " order by MODULE_NAME       " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                using (DbDataAdapter da = dbf.CreateDataAdapter())
                                {
                                    ((IDbDataAdapter)da).SelectCommand = cmd;
                                    dtACLACCESS = new DataTable();
                                    da.Fill(dtACLACCESS);
                                }
                            }

                            string    sCUSTOM_MODULE = "ACL_ROLES";
                            DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                            using (IDbTransaction trn = con.BeginTransaction())
                            {
                                try
                                {
                                    SqlProcs.spACL_ROLES_Update(ref gID
                                                                , new DynamicControl(this, "NAME").Text
                                                                , new DynamicControl(this, "DESCRIPTION").Text
                                                                , trn
                                                                );
                                    SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);

                                    foreach (DataRow row in dtACLACCESS.Rows)
                                    {
                                        string sMODULE_NAME = Sql.ToString(row["MODULE_NAME"]);
                                        // 04/25/2006 Paul.  FindControl needs to be executed on the DataGridItem.  I'm not sure why.
                                        DropDownList lstAccess       = lstAccess = ctlAccessView.FindACLControl(sMODULE_NAME, "access");
                                        DropDownList lstView         = ctlAccessView.FindACLControl(sMODULE_NAME, "view");
                                        DropDownList lstList         = ctlAccessView.FindACLControl(sMODULE_NAME, "list");
                                        DropDownList lstEdit         = ctlAccessView.FindACLControl(sMODULE_NAME, "edit");
                                        DropDownList lstDelete       = ctlAccessView.FindACLControl(sMODULE_NAME, "delete");
                                        DropDownList lstImport       = ctlAccessView.FindACLControl(sMODULE_NAME, "import");
                                        DropDownList lstExport       = ctlAccessView.FindACLControl(sMODULE_NAME, "export");
                                        Guid         gActionAccessID = Guid.Empty;
                                        Guid         gActionViewID   = Guid.Empty;
                                        Guid         gActionListID   = Guid.Empty;
                                        Guid         gActionEditID   = Guid.Empty;
                                        Guid         gActionDeleteID = Guid.Empty;
                                        Guid         gActionImportID = Guid.Empty;
                                        Guid         gActionExportID = Guid.Empty;
                                        if (lstAccess != null)
                                        {
                                            SqlProcs.spACL_ROLES_ACTIONS_Update(ref gActionAccessID, gID, "access", sMODULE_NAME, Sql.ToInteger(lstAccess.SelectedValue), trn);
                                        }
                                        if (lstView != null)
                                        {
                                            SqlProcs.spACL_ROLES_ACTIONS_Update(ref gActionViewID, gID, "view", sMODULE_NAME, Sql.ToInteger(lstView.SelectedValue), trn);
                                        }
                                        if (lstList != null)
                                        {
                                            SqlProcs.spACL_ROLES_ACTIONS_Update(ref gActionListID, gID, "list", sMODULE_NAME, Sql.ToInteger(lstList.SelectedValue), trn);
                                        }
                                        if (lstEdit != null)
                                        {
                                            SqlProcs.spACL_ROLES_ACTIONS_Update(ref gActionEditID, gID, "edit", sMODULE_NAME, Sql.ToInteger(lstEdit.SelectedValue), trn);
                                        }
                                        if (lstDelete != null)
                                        {
                                            SqlProcs.spACL_ROLES_ACTIONS_Update(ref gActionDeleteID, gID, "delete", sMODULE_NAME, Sql.ToInteger(lstDelete.SelectedValue), trn);
                                        }
                                        if (lstImport != null)
                                        {
                                            SqlProcs.spACL_ROLES_ACTIONS_Update(ref gActionImportID, gID, "import", sMODULE_NAME, Sql.ToInteger(lstImport.SelectedValue), trn);
                                        }
                                        if (lstExport != null)
                                        {
                                            SqlProcs.spACL_ROLES_ACTIONS_Update(ref gActionExportID, gID, "export", sMODULE_NAME, Sql.ToInteger(lstExport.SelectedValue), trn);
                                        }
                                        //break;
                                    }
                                    trn.Commit();
                                }
                                catch (Exception ex)
                                {
                                    trn.Rollback();
                                    SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                    ctlEditButtons.ErrorText = ex.Message;
                                    return;
                                }
                            }
                        }
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
                catch (Exception ex)
                {
                    SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                    ctlEditButtons.ErrorText = ex.Message;
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
示例#8
0
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            // 08/21/2005 Paul.  Redirect to parent if that is where the note was originated.
            Guid   gPARENT_ID   = Sql.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            try
            {
                SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "MEETINGS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                SqlProcs.spMEETINGS_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "NAME").Text
                                    , new DynamicControl(this, "LOCATION").Text
                                    , new DynamicControl(this, "DURATION_HOURS").IntegerValue
                                    , new DynamicControl(this, "DURATION_MINUTES").IntegerValue
                                    , new DynamicControl(this, "DATE_START").DateValue
                                    , new DynamicControl(this, "STATUS").SelectedValue
                                    , new DynamicControl(this, "PARENT_TYPE").SelectedValue
                                    , new DynamicControl(this, "PARENT_ID").ID                                                        // 01/31/2006 Paul.  Bug Fix, should be PARENT_ID, not APARENT_ID.
                                    , new DynamicControl(this, "SHOULD_REMIND").Checked ? new DynamicControl(this, "REMINDER_TIME").IntegerValue : -1
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , txtINVITEE_ID.Value
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
            else if (e.CommandName == "Invitees.Add")
            {
                if (txtINVITEE_ID.Value.Length > 0)
                {
                    txtINVITEE_ID.Value += ",";
                }
                txtINVITEE_ID.Value     += e.CommandArgument;
                ctlInviteesView.INVITEES = txtINVITEE_ID.Value.Split(',');
                BindSchedule();
            }
            else if (e.CommandName == "Invitees.Delete")
            {
                string        sDELETE_ID  = e.CommandArgument.ToString().ToLower();
                string[]      arrINVITEES = txtINVITEE_ID.Value.Split(',');
                StringBuilder sb          = new StringBuilder();
                foreach (string sINVITEE_ID in arrINVITEES)
                {
                    if (sINVITEE_ID != sDELETE_ID)
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append(",");
                        }
                        sb.Append(sINVITEE_ID);
                    }
                }
                txtINVITEE_ID.Value      = sb.ToString();
                ctlInviteesView.INVITEES = txtINVITEE_ID.Value.Split(',');
                BindSchedule();
            }
            else if (e.CommandName == "Search")
            {
                BindSchedule();
            }
        }
 protected void Page_Command(Object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         // 01/16/2006 Paul.  Enable validator before validating page.
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
         if (Page.IsValid)
         {
             string            sCUSTOM_MODULE = "PRODUCT_TEMPLATES";
             DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
             DbProviderFactory dbf            = DbProviderFactories.GetFactory();
             using (IDbConnection con = dbf.CreateConnection())
             {
                 con.Open();
                 using (IDbTransaction trn = con.BeginTransaction())
                 {
                     try
                     {
                         SqlProcs.spPRODUCT_TEMPLATES_Update
                             (ref gID
                             , new DynamicControl(this, "NAME").Text
                             , new DynamicControl(this, "STATUS").SelectedValue
                             , new DynamicControl(this, "QUANTITY").IntegerValue
                             , new DynamicControl(this, "DATE_AVAILABLE").DateValue
                             , new DynamicControl(this, "DATE_COST_PRICE").DateValue
                             , new DynamicControl(this, "ACCOUNT_ID").ID
                             , new DynamicControl(this, "MANUFACTURER_ID").ID
                             , new DynamicControl(this, "CATEGORY_ID").ID
                             , new DynamicControl(this, "TYPE_ID").ID
                             , new DynamicControl(this, "WEBSITE").Text
                             , new DynamicControl(this, "MFT_PART_NUM").Text
                             , new DynamicControl(this, "VENDOR_PART_NUM").Text
                             , new DynamicControl(this, "TAX_CLASS").SelectedValue
                             , new DynamicControl(this, "WEIGHT").FloatValue
                             , new DynamicControl(this, "CURRENCY_ID").ID
                             , new DynamicControl(this, "COST_PRICE").DecimalValue
                             , new DynamicControl(this, "LIST_PRICE").DecimalValue
                             , new DynamicControl(this, "DISCOUNT_PRICE").DecimalValue
                             , new DynamicControl(this, "PRICING_FACTOR").IntegerValue
                             , new DynamicControl(this, "PRICING_FORMULA").SelectedValue
                             , new DynamicControl(this, "SUPPORT_NAME").Text
                             , new DynamicControl(this, "SUPPORT_CONTACT").Text
                             , new DynamicControl(this, "SUPPORT_DESCRIPTION").Text
                             , new DynamicControl(this, "SUPPORT_TERM").SelectedValue
                             , new DynamicControl(this, "DESCRIPTION").Text
                             , trn
                             );
                         SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                         trn.Commit();
                     }
                     catch (Exception ex)
                     {
                         trn.Rollback();
                         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                         ctlEditButtons.ErrorText = ex.Message;
                         return;
                     }
                 }
             }
             Response.Redirect("view.aspx?ID=" + gID.ToString());
         }
     }
     else if (e.CommandName == "Cancel")
     {
         if (Sql.IsEmptyGuid(gID))
         {
             Response.Redirect("default.aspx");
         }
         else
         {
             Response.Redirect("view.aspx?ID=" + gID.ToString());
         }
     }
 }
示例#10
0
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            // 06/08/2006 Paul.  Redirect to parent if that is where the note was originated.
            Guid   gPARENT_ID   = Sql.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            try
            {
                SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                TextBox         txtNAME = FindControl("NAME") as TextBox;
                HtmlInputHidden txtPRODUCT_TEMPLATE_ID = FindControl("PRODUCT_TEMPLATE_ID") as HtmlInputHidden;
                // 07/05/2006 Paul.  The NAME field can be derived from a product template or manually entered.
                // In order to fake-out the normal required-field mechanism, assign the empty Guid to the template ID.
                // The name cannot be null, so if it is, then clear the template ID.
                if (Sql.IsEmptyString(txtNAME.Text.Trim()))
                {
                    txtPRODUCT_TEMPLATE_ID.Value = String.Empty;
                }
                else if (Sql.IsEmptyString(txtPRODUCT_TEMPLATE_ID.Value))
                {
                    txtPRODUCT_TEMPLATE_ID.Value = Guid.Empty.ToString();
                }

                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".CostView", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".MftView", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "PRODUCTS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                SqlProcs.spPRODUCTS_Update
                                    (ref gID
                                    , new DynamicControl(this, "PRODUCT_TEMPLATE_ID").ID
                                    , new DynamicControl(this, "NAME").Text
                                    , new DynamicControl(this, "STATUS").SelectedValue
                                    , new DynamicControl(this, "ACCOUNT_ID").ID
                                    , new DynamicControl(this, "CONTACT_ID").ID
                                    , new DynamicControl(this, "QUANTITY").IntegerValue
                                    , new DynamicControl(this, "DATE_PURCHASED").DateValue
                                    , new DynamicControl(this, "DATE_SUPPORT_EXPIRES").DateValue
                                    , new DynamicControl(this, "DATE_SUPPORT_STARTS").DateValue
                                    , new DynamicControl(this, "MANUFACTURER_ID").ID
                                    , new DynamicControl(this, "CATEGORY_ID").ID
                                    , new DynamicControl(this, "TYPE_ID").ID
                                    , new DynamicControl(this, "WEBSITE").Text
                                    , new DynamicControl(this, "MFT_PART_NUM").Text
                                    , new DynamicControl(this, "VENDOR_PART_NUM").Text
                                    , new DynamicControl(this, "SERIAL_NUMBER").Text
                                    , new DynamicControl(this, "ASSET_NUMBER").Text
                                    , new DynamicControl(this, "TAX_CLASS").SelectedValue
                                    , new DynamicControl(this, "WEIGHT").FloatValue
                                    , new DynamicControl(this, "CURRENCY_ID").ID
                                    , new DynamicControl(this, "COST_PRICE").DecimalValue
                                    , new DynamicControl(this, "LIST_PRICE").DecimalValue
                                    , new DynamicControl(this, "BOOK_VALUE").DecimalValue
                                    , new DynamicControl(this, "BOOK_VALUE_DATE").DateValue
                                    , new DynamicControl(this, "DISCOUNT_PRICE").DecimalValue
                                    , new DynamicControl(this, "PRICING_FACTOR").IntegerValue
                                    , new DynamicControl(this, "PRICING_FORMULA").SelectedValue
                                    , new DynamicControl(this, "SUPPORT_NAME").Text
                                    , new DynamicControl(this, "SUPPORT_CONTACT").Text
                                    , new DynamicControl(this, "SUPPORT_DESCRIPTION").Text
                                    , new DynamicControl(this, "SUPPORT_TERM").SelectedValue
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
 protected void ValidateEditViewFields(string sEDIT_NAME)
 {
     // 11/17/2007 Paul.  Convert all view requests to a mobile request if appropriate.
     sEDIT_NAME = sEDIT_NAME + (this.IsMobile ? ".Mobile" : "");
     SplendidDynamic.ValidateEditViewFields(sEDIT_NAME, this);
 }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            // 06/08/2006 Paul.  Redirect to parent if that is where the note was originated.
            Guid   gPARENT_ID   = Sql.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            try
            {
                SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditAddress", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditDescription", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "QUOTES";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                SqlProcs.spQUOTES_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "NAME").Text
                                    , new DynamicControl(this, "OPPORTUNITY_ID").ID
                                    , new DynamicControl(this, "QUOTE_TYPE").SelectedValue
                                    , new DynamicControl(this, "PAYMENT_TERMS").SelectedValue
                                    , new DynamicControl(this, "ORDER_STAGE").SelectedValue
                                    , new DynamicControl(this, "QUOTE_STAGE").SelectedValue
                                    , new DynamicControl(this, "PURCHASE_ORDER_NUM").Text
                                    , new DynamicControl(this, "ORIGINAL_PO_DATE").DateValue
                                    , new DynamicControl(this, "DATE_QUOTE_CLOSED").DateValue
                                    , new DynamicControl(this, "DATE_QUOTE_EXPECTED_CLOSED").DateValue
                                    , new DynamicControl(this, "DATE_ORDER_SHIPPED").DateValue
                                    , new DynamicControl(this, "SHOW_LINE_NUMS").Checked
                                    , new DynamicControl(this, "CALC_GRAND_TOTAL").Checked
                                    , new DynamicControl(this, "CURRENCY_ID").ID
                                    , new DynamicControl(this, "TAXRATE_ID").ID
                                    , new DynamicControl(this, "SHIPPER_ID").ID
                                    , new DynamicControl(this, "SUBTOTAL").DecimalValue
                                    , new DynamicControl(this, "SHIPPING").DecimalValue
                                    , new DynamicControl(this, "TAX").DecimalValue
                                    , new DynamicControl(this, "TOTAL").DecimalValue
                                    , new DynamicControl(this, "BILLING_ACCOUNT_ID").ID
                                    , new DynamicControl(this, "BILLING_CONTACT_ID").ID
                                    , new DynamicControl(this, "BILLING_ADDRESS_STREET").Text
                                    , new DynamicControl(this, "BILLING_ADDRESS_CITY").Text
                                    , new DynamicControl(this, "BILLING_ADDRESS_STATE").Text
                                    , new DynamicControl(this, "BILLING_ADDRESS_POSTALCODE").Text
                                    , new DynamicControl(this, "BILLING_ADDRESS_COUNTRY").Text
                                    , new DynamicControl(this, "SHIPPING_ACCOUNT_ID").ID
                                    , new DynamicControl(this, "SHIPPING_CONTACT_ID").ID
                                    , new DynamicControl(this, "SHIPPING_ADDRESS_STREET").Text
                                    , new DynamicControl(this, "SHIPPING_ADDRESS_CITY").Text
                                    , new DynamicControl(this, "SHIPPING_ADDRESS_STATE").Text
                                    , new DynamicControl(this, "SHIPPING_ADDRESS_POSTALCODE").Text
                                    , new DynamicControl(this, "SHIPPING_ADDRESS_COUNTRY").Text
                                    , new DynamicControl(this, "DESCRIPTION").Text

                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            Guid   gPARENT_ID   = Sql.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            try
            {
                SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditAddress", this);
                if (Page.IsValid)
                {
                    string      sUSER_PREFERENCES = String.Empty;
                    XmlDocument xml = new XmlDocument();
                    try
                    {
                        try
                        {
                            sUSER_PREFERENCES = Sql.ToString(ViewState["USER_PREFERENCES"]);
                            xml.LoadXml(sUSER_PREFERENCES);
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                            xml.AppendChild(xml.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));
                            xml.AppendChild(xml.CreateElement("USER_PREFERENCE"));
                        }
                        // user_settings
                        XmlUtil.SetSingleNode(xml, "gridline", chkGRIDLINE.Checked ? "true" : "false");
                        XmlUtil.SetSingleNode(xml, "culture", lstLANGUAGE.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "theme", lstTHEME.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "dateformat", lstDATE_FORMAT.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "timeformat", lstTIME_FORMAT.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "timezone", lstTIMEZONE.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "currency_id", lstCURRENCY.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "num_grp_sep", txtGROUP_SEPARATOR.Text);
                        XmlUtil.SetSingleNode(xml, "dec_sep", txtDECIMAL_SEPARATOR.Text);
                        // 08/05/2006 Paul.  Remove stub of unsupported code. Reminder is not supported at this time.
                        //XmlUtil.SetSingleNode(xml, "reminder_time"       , chkSHOULD_REMIND.Checked ? lstREMINDER_TIME.SelectedValue : "0" );
                        // mail_options

                        string sMAIL_SMTPPASS = Sql.ToString(ViewState["mail_smtppass"]);
                        // 08/06/2005 Paul.  Password might be our empty value.
                        TextBox txtMAIL_SMTPPASS = FindControl("MAIL_SMTPPASS") as TextBox;
                        if (txtMAIL_SMTPPASS != null)
                        {
                            // 08/05/2006 Paul.  Allow the password to be cleared.
                            if (txtMAIL_SMTPPASS.Text != sEMPTY_PASSWORD)
                            {
                                sMAIL_SMTPPASS = txtMAIL_SMTPPASS.Text;
                            }
                        }

                        XmlUtil.SetSingleNode(xml, "mail_fromname", new DynamicControl(this, "MAIL_FROMNAME").Text);
                        XmlUtil.SetSingleNode(xml, "mail_fromaddress", new DynamicControl(this, "MAIL_FROMADDRESS").Text);
                        XmlUtil.SetSingleNode(xml, "mail_smtpserver", new DynamicControl(this, "MAIL_SMTPSERVER").Text);
                        XmlUtil.SetSingleNode(xml, "mail_smtpport", new DynamicControl(this, "MAIL_SMTPPORT").Text);
                        XmlUtil.SetSingleNode(xml, "mail_sendtype", new DynamicControl(this, "MAIL_SENDTYPE").Text);
                        XmlUtil.SetSingleNode(xml, "mail_smtpauth_req", new DynamicControl(this, "MAIL_SMTPAUTH_REQ").Checked ? "true" : "false");
                        XmlUtil.SetSingleNode(xml, "mail_smtpuser", new DynamicControl(this, "MAIL_SMTPUSER").Text);
                        XmlUtil.SetSingleNode(xml, "mail_smtppass", sMAIL_SMTPPASS);

                        // freebusy
                        // 08/05/2006 Paul.  Remove stub of unsupported code. Calendar Publish Key is not supported at this time.
                        //XmlUtil.SetSingleNode(xml, "calendar_publish_key", txtCALENDAR_PUBLISH_KEY .Text         );
                        //XmlUtil.SetSingleNode(xml, "calendar_publish_url", txtCALENDAR_PUBLISH_URL .Text         );
                        //XmlUtil.SetSingleNode(xml, "calendar_search_url" , txtCALENDAR_SEARCH_URL  .Text         );
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                    }
                    if (Sql.ToBoolean(Application["CONFIG.XML_UserPreferences"]))
                    {
                        sUSER_PREFERENCES = xml.OuterXml;
                    }
                    else
                    {
                        sUSER_PREFERENCES = XmlUtil.ConvertToPHP(xml.DocumentElement);
                    }

                    // 12/06/2005 Paul.  Need to prevent duplicate users.
                    string            sUSER_NAME = txtUSER_NAME.Text.Trim();
                    DbProviderFactory dbf        = DbProviderFactories.GetFactory();
                    try
                    {
                        if (!Sql.IsEmptyString(sUSER_NAME))
                        {
                            using (IDbConnection con = dbf.CreateConnection())
                            {
                                string sSQL;
                                sSQL = "select USER_NAME             " + ControlChars.CrLf
                                       + "  from vwUSERS               " + ControlChars.CrLf
                                       + " where USER_NAME = @USER_NAME" + ControlChars.CrLf;
                                using (IDbCommand cmd = con.CreateCommand())
                                {
                                    cmd.CommandText = sSQL;
                                    Sql.AddParameter(cmd, "@USER_NAME", sUSER_NAME);
                                    if (!Sql.IsEmptyGuid(gID))
                                    {
                                        // 12/06/2005 Paul.  Only include the ID if it is not null as we cannot compare NULL to anything.
                                        cmd.CommandText += "   and ID <> @ID" + ControlChars.CrLf;
                                        Sql.AddParameter(cmd, "@ID", gID);
                                    }
                                    con.Open();
                                    using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                    {
                                        if (rdr.Read())
                                        {
                                            string sMESSAGE = String.Empty;
                                            sMESSAGE = String.Format(L10n.Term("Users.ERR_USER_NAME_EXISTS_1") + "{0}" + L10n.Term("Users.ERR_USER_NAME_EXISTS_2"), sUSER_NAME);
                                            throw(new Exception(sMESSAGE));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                        ctlEditButtons.ErrorText = ex.Message;
                        return;
                    }

                    string    sCUSTOM_MODULE = "USERS";
                    DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                bool bNewUser = Sql.IsEmptyGuid(gID);
                                // 04/24/2006 Paul.  Upgrade to SugarCRM 4.2 Schema.
                                SqlProcs.spUSERS_Update
                                    (ref gID
                                    , sUSER_NAME
                                    , txtFIRST_NAME.Text
                                    , txtLAST_NAME.Text
                                    , new DynamicControl(this, "REPORTS_TO_ID").ID
                                    , (Security.IS_ADMIN ? chkIS_ADMIN.Checked : Sql.ToBoolean(ViewState["IS_ADMIN"]))
                                    , chkRECEIVE_NOTIFICATIONS.Checked
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , new DynamicControl(this, "TITLE").Text
                                    , new DynamicControl(this, "DEPARTMENT").Text
                                    , new DynamicControl(this, "PHONE_HOME").Text
                                    , new DynamicControl(this, "PHONE_MOBILE").Text
                                    , new DynamicControl(this, "PHONE_WORK").Text
                                    , new DynamicControl(this, "PHONE_OTHER").Text
                                    , new DynamicControl(this, "PHONE_FAX").Text
                                    , new DynamicControl(this, "EMAIL1").Text
                                    , new DynamicControl(this, "EMAIL2").Text
                                    , lstSTATUS.SelectedValue
                                    , new DynamicControl(this, "ADDRESS_STREET").Text
                                    , new DynamicControl(this, "ADDRESS_CITY").Text
                                    , new DynamicControl(this, "ADDRESS_STATE").Text
                                    , new DynamicControl(this, "ADDRESS_POSTALCODE").Text
                                    , new DynamicControl(this, "ADDRESS_COUNTRY").Text
                                    , sUSER_PREFERENCES
                                    , chkPORTAL_ONLY.Checked
                                    , new DynamicControl(this, "EMPLOYEE_STATUS").SelectedValue
                                    , new DynamicControl(this, "MESSENGER_ID").Text
                                    , new DynamicControl(this, "MESSENGER_TYPE").SelectedValue
                                    , sMODULE
                                    , gPARENT_ID
                                    , new DynamicControl(this, "IS_GROUP").Checked
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                                // 09/09/2006 Paul.  Refresh cached user information.
                                if (bNewUser)
                                {
                                    SplendidCache.ClearUsers();
                                }
                                // 08/27/2005 Paul. Reload session with user preferences.
                                // 08/30/2005 Paul. Only reload preferences the user is editing his own profile.
                                // We want to allow an administrator to update other user profiles.
                                if (Security.USER_ID == gID)
                                {
                                    SplendidInit.LoadUserPreferences(gID, lstTHEME.SelectedValue, lstLANGUAGE.SelectedValue);
                                }
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else if (bMyAccount)
                    {
                        Response.Redirect("MyAccount.aspx");
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (bMyAccount)
                {
                    Response.Redirect("MyAccount.aspx");
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
 protected void Page_Command(Object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         // 01/16/2006 Paul.  Enable validator before validating page.
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditAddress", this);
         if (Page.IsValid)
         {
             string            sCUSTOM_MODULE = "USERS";
             DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
             DbProviderFactory dbf            = DbProviderFactories.GetFactory();
             using (IDbConnection con = dbf.CreateConnection())
             {
                 con.Open();
                 using (IDbTransaction trn = con.BeginTransaction())
                 {
                     try
                     {
                         SqlProcs.spEMPLOYEES_Update
                             (ref gID
                             , new DynamicControl(this, "FIRST_NAME").Text
                             , new DynamicControl(this, "LAST_NAME").Text
                             , new DynamicControl(this, "REPORTS_TO_ID").ID
                             , new DynamicControl(this, "DESCRIPTION").Text
                             , new DynamicControl(this, "TITLE").Text
                             , new DynamicControl(this, "DEPARTMENT").Text
                             , new DynamicControl(this, "PHONE_HOME").Text
                             , new DynamicControl(this, "PHONE_MOBILE").Text
                             , new DynamicControl(this, "PHONE_WORK").Text
                             , new DynamicControl(this, "PHONE_OTHER").Text
                             , new DynamicControl(this, "PHONE_FAX").Text
                             , new DynamicControl(this, "EMAIL1").Text
                             , new DynamicControl(this, "EMAIL2").Text
                             , new DynamicControl(this, "ADDRESS_STREET").Text
                             , new DynamicControl(this, "ADDRESS_CITY").Text
                             , new DynamicControl(this, "ADDRESS_STATE").Text
                             , new DynamicControl(this, "ADDRESS_POSTALCODE").Text
                             , new DynamicControl(this, "ADDRESS_COUNTRY").Text
                             , new DynamicControl(this, "EMPLOYEE_STATUS").SelectedValue
                             , new DynamicControl(this, "MESSENGER_ID").Text
                             , new DynamicControl(this, "MESSENGER_TYPE").SelectedValue
                             , trn
                             );
                         SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                         trn.Commit();
                     }
                     catch (Exception ex)
                     {
                         trn.Rollback();
                         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                         ctlEditButtons.ErrorText = ex.Message;
                         return;
                     }
                 }
             }
             Response.Redirect("view.aspx?ID=" + gID.ToString());
         }
     }
     else if (e.CommandName == "Cancel")
     {
         if (Sql.IsEmptyGuid(gID))
         {
             Response.Redirect("default.aspx");
         }
         else
         {
             Response.Redirect("view.aspx?ID=" + gID.ToString());
         }
     }
 }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            // 08/21/2005 Paul.  Redirect to parent if that is where the note was originated.
            Guid   gPARENT_ID   = Sql.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            try
            {
                SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "OPPORTUNITIES";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                SqlProcs.spOPPORTUNITIES_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "ACCOUNT_ID").ID
                                    , new DynamicControl(this, "NAME").Text
                                    , new DynamicControl(this, "OPPORTUNITY_TYPE").SelectedValue
                                    , new DynamicControl(this, "LEAD_SOURCE").SelectedValue
                                    , new DynamicControl(this, "AMOUNT").DecimalValue
                                    , new DynamicControl(this, "CURRENCY_ID").ID                                           // 03/04/2006 Paul.  Correct name is CURRENCY_ID.
                                    , new DynamicControl(this, "DATE_CLOSED").DateValue
                                    , new DynamicControl(this, "NEXT_STEP").Text
                                    , new DynamicControl(this, "SALES_STAGE").SelectedValue
                                    , new DynamicControl(this, "PROBABILITY").FloatValue
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , sMODULE
                                    , gPARENT_ID
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
示例#16
0
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Save")
            {
                Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID))
                {
                    // 03/04/2006 Paul.  The Enable flag cannot be modified prior to ValidateEditViewFields because the change will get over-ridden.
                    //RequiredFieldValidator reqCONTENT  = FindControl("CONTENT_REQUIRED" ) as RequiredFieldValidator;
                    //RequiredFieldValidator reqREVISION = FindControl("REVISION_REQUIRED") as RequiredFieldValidator;
                    //if ( reqCONTENT != null )
                    //	reqCONTENT.Enabled = false;
                    //if ( reqREVISION != null )
                    //	reqREVISION.Enabled = false;
                }
                // 01/16/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "DOCUMENTS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                HtmlInputFile  fileCONTENT = FindControl("CONTENT") as HtmlInputFile;
                                HttpPostedFile pstCONTENT  = null;
                                if (fileCONTENT != null)
                                {
                                    pstCONTENT = fileCONTENT.PostedFile;
                                }
                                // 03/04/2006 Paul.  This is a new document if gID and gDuplicateID are both empty.
                                bool bNewDocument = Sql.IsEmptyGuid(gID) && Sql.IsEmptyGuid(gDuplicateID);
                                if (bNewDocument)
                                {
                                    //die("ERROR: uploaded file was too big: max filesize: {$sugar_config['upload_maxsize']}");
                                    if (pstCONTENT != null)
                                    {
                                        long lFileSize      = pstCONTENT.ContentLength;
                                        long lUploadMaxSize = Sql.ToLong(Application["CONFIG.upload_maxsize"]);
                                        if ((lUploadMaxSize > 0) && (lFileSize > lUploadMaxSize))
                                        {
                                            throw(new Exception("ERROR: uploaded file was too big: max filesize: " + lUploadMaxSize.ToString()));
                                        }
                                    }
                                }
                                // 04/24/2006 Paul.  Upgrade to SugarCRM 4.2 Schema.
                                SqlProcs.spDOCUMENTS_Update
                                    (ref gID
                                    , new DynamicControl(this, "DOCUMENT_NAME").Text
                                    , new DynamicControl(this, "ACTIVE_DATE").DateValue
                                    , new DynamicControl(this, "EXP_DATE").DateValue
                                    , new DynamicControl(this, "CATEGORY_ID").SelectedValue
                                    , new DynamicControl(this, "SUBCATEGORY_ID").SelectedValue
                                    , new DynamicControl(this, "STATUS_ID").SelectedValue
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , new DynamicControl(this, "MAIL_MERGE_DOCUMENT").Checked
                                    , new DynamicControl(this, "RELATED_DOC_ID").ID
                                    , new DynamicControl(this, "RELATED_DOC_REV_ID").ID
                                    , new DynamicControl(this, "IS_TEMPLATE").Checked
                                    , new DynamicControl(this, "TEMPLATE_TYPE").Text
                                    , trn
                                    );
                                if (bNewDocument)
                                {
                                    if (pstCONTENT != null)
                                    {
                                        // 08/20/2005 Paul.  File may not have been provided.
                                        if (pstCONTENT.FileName.Length > 0)
                                        {
                                            string sFILENAME       = Path.GetFileName(pstCONTENT.FileName);
                                            string sFILE_EXT       = Path.GetExtension(sFILENAME);
                                            string sFILE_MIME_TYPE = pstCONTENT.ContentType;

                                            Guid gRevisionID = Guid.Empty;
                                            // 01/16/2006 Paul.  spDOCUMENT_REVISIONS_Insert needs to be in the transaction,
                                            // otherwise the entire transaction will timeout. This is because the transaction has
                                            // locked the tables that are needed by spDOCUMENT_REVISIONS_Insert.
                                            SqlProcs.spDOCUMENT_REVISIONS_Insert
                                                (ref gRevisionID
                                                , gID
                                                , new DynamicControl(this, "REVISION").Text
                                                , "Document Created"
                                                , sFILENAME
                                                , sFILE_EXT
                                                , sFILE_MIME_TYPE
                                                , trn
                                                );
                                            LoadFile(gRevisionID, pstCONTENT.InputStream, trn);
                                        }
                                    }
                                }
                                else if (Sql.IsEmptyGuid(Request["ID"]) && !Sql.IsEmptyGuid(gDuplicateID))
                                {
                                    Guid gRevisionID = Guid.Empty;
                                    // 03/04/2006 Paul.  We need a separate procedure to copy the document stored in the revisions table.
                                    SqlProcs.spDOCUMENT_REVISIONS_Duplicate
                                        (ref gRevisionID
                                        , gID
                                        , gDuplicateID
                                        , new DynamicControl(this, "REVISION").Text
                                        , "Document Created"
                                        , trn
                                        );
                                }

                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            // 08/21/2005 Paul.  Redirect to parent if that is where the note was originated.
            Guid   gPARENT_ID   = Sql.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            try
            {
                SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditAddress", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditDescription", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "CONTACTS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                SqlProcs.spCONTACTS_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "SALUTATION").SelectedValue
                                    , new DynamicControl(this, "FIRST_NAME").Text
                                    , new DynamicControl(this, "LAST_NAME").Text
                                    , new DynamicControl(this, "ACCOUNT_ID").ID
                                    , new DynamicControl(this, "LEAD_SOURCE").SelectedValue
                                    , new DynamicControl(this, "TITLE").Text
                                    , new DynamicControl(this, "DEPARTMENT").Text
                                    , new DynamicControl(this, "REPORTS_TO_ID").ID
                                    , new DynamicControl(this, "BIRTHDATE").DateValue
                                    , new DynamicControl(this, "DO_NOT_CALL").Checked
                                    , new DynamicControl(this, "PHONE_HOME").Text
                                    , new DynamicControl(this, "PHONE_MOBILE").Text
                                    , new DynamicControl(this, "PHONE_WORK").Text
                                    , new DynamicControl(this, "PHONE_OTHER").Text
                                    , new DynamicControl(this, "PHONE_FAX").Text
                                    , new DynamicControl(this, "EMAIL1").Text
                                    , new DynamicControl(this, "EMAIL2").Text
                                    , new DynamicControl(this, "ASSISTANT").Text
                                    , new DynamicControl(this, "ASSISTANT_PHONE").Text
                                    , new DynamicControl(this, "EMAIL_OPT_OUT").Checked
                                    , new DynamicControl(this, "INVALID_EMAIL").Checked
                                    , new DynamicControl(this, "PRIMARY_ADDRESS_STREET").Text
                                    , new DynamicControl(this, "PRIMARY_ADDRESS_CITY").Text
                                    , new DynamicControl(this, "PRIMARY_ADDRESS_STATE").Text
                                    , new DynamicControl(this, "PRIMARY_ADDRESS_POSTALCODE").Text
                                    , new DynamicControl(this, "PRIMARY_ADDRESS_COUNTRY").Text
                                    , new DynamicControl(this, "ALT_ADDRESS_STREET").Text
                                    , new DynamicControl(this, "ALT_ADDRESS_CITY").Text
                                    , new DynamicControl(this, "ALT_ADDRESS_STATE").Text
                                    , new DynamicControl(this, "ALT_ADDRESS_POSTALCODE").Text
                                    , new DynamicControl(this, "ALT_ADDRESS_COUNTRY").Text
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , sMODULE
                                    , gPARENT_ID
                                    , new DynamicControl(this, "SYNC_CONTACT").Checked
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            // 08/21/2005 Paul.  Redirect to parent if that is where the note was originated.
            Guid   gPARENT_ID   = Sql.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            try
            {
                SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditAddress", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditDescription", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "ACCOUNTS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                SqlProcs.spACCOUNTS_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "NAME").Text
                                    , new DynamicControl(this, "ACCOUNT_TYPE").SelectedValue
                                    , new DynamicControl(this, "PARENT_ID").ID
                                    , new DynamicControl(this, "INDUSTRY").SelectedValue
                                    , new DynamicControl(this, "ANNUAL_REVENUE").Text
                                    , new DynamicControl(this, "PHONE_FAX").Text
                                    , new DynamicControl(this, "BILLING_ADDRESS_STREET").Text
                                    , new DynamicControl(this, "BILLING_ADDRESS_CITY").Text
                                    , new DynamicControl(this, "BILLING_ADDRESS_STATE").Text
                                    , new DynamicControl(this, "BILLING_ADDRESS_POSTALCODE").Text
                                    , new DynamicControl(this, "BILLING_ADDRESS_COUNTRY").Text
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , new DynamicControl(this, "RATING").Text
                                    , new DynamicControl(this, "PHONE_OFFICE").Text
                                    , new DynamicControl(this, "PHONE_ALTERNATE").Text
                                    , new DynamicControl(this, "EMAIL1").Text
                                    , new DynamicControl(this, "EMAIL2").Text
                                    , new DynamicControl(this, "WEBSITE").Text
                                    , new DynamicControl(this, "OWNERSHIP").Text
                                    , new DynamicControl(this, "EMPLOYEES").Text
                                    , new DynamicControl(this, "SIC_CODE").Text
                                    , new DynamicControl(this, "TICKER_SYMBOL").Text
                                    , new DynamicControl(this, "SHIPPING_ADDRESS_STREET").Text
                                    , new DynamicControl(this, "SHIPPING_ADDRESS_CITY").Text
                                    , new DynamicControl(this, "SHIPPING_ADDRESS_STATE").Text
                                    , new DynamicControl(this, "SHIPPING_ADDRESS_POSTALCODE").Text
                                    , new DynamicControl(this, "SHIPPING_ADDRESS_COUNTRY").Text
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/Accounts/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/Accounts/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }