public override void SqlSearchClause(IDbCommand cmd)
 {
     // 07/18/2006 Paul.  SqlFilterMode.Contains behavior has be deprecated. It is now the same as SqlFilterMode.StartsWith.
     Sql.AppendParameter(cmd, txtNAME.Text, 50, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtMFT_PART_NUM.Text, 50, Sql.SqlFilterMode.StartsWith, "MFT_PART_NUM");
     Sql.AppendParameter(cmd, txtVENDOR_PART_NUM.Text, 50, Sql.SqlFilterMode.StartsWith, "VENDOR_PART_NUM");
     Sql.AppendParameter(cmd, txtSUPPORT_CONTACT.Text, 50, Sql.SqlFilterMode.StartsWith, "SUPPORT_CONTACT");
     Sql.AppendParameter(cmd, txtWEBSITE.Text, 255, Sql.SqlFilterMode.StartsWith, "WEBSITE");
     Sql.AppendParameter(cmd, txtSUPPORT_TERM.Text, 25, Sql.SqlFilterMode.StartsWith, "SUPPORT_TERM");
     Sql.AppendParameter(cmd, lstTAX_CLASS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "TAX_CLASS");
     Sql.AppendParameter(cmd, lstSTATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "STATUS");
     if (!Sql.IsEmptyGuid(lstCATEGORY.SelectedValue))
     {
         Sql.AppendParameter(cmd, Sql.ToGuid(lstCATEGORY.SelectedValue), "CATEGORY_ID");
     }
     if (!Sql.IsEmptyGuid(lstMANUFACTURER.SelectedValue))
     {
         Sql.AppendParameter(cmd, Sql.ToGuid(lstMANUFACTURER.SelectedValue), "MANUFACTURER_ID");
     }
     if (!Sql.IsEmptyGuid(lstTYPE.SelectedValue))
     {
         Sql.AppendParameter(cmd, Sql.ToGuid(lstTYPE.SelectedValue), "TYPE_ID");
     }
     // 07/09/2006 Paul.  Date is no longer converted in the DatePicker control, so convert it here to server time.
     Sql.AppendParameter(cmd, T10n.ToServerTime(ctlDATE_COST_PRICE.Value), "DATE_COST_PRICE");
     Sql.AppendParameter(cmd, T10n.ToServerTime(ctlDATE_AVAILABLE.Value), "DATE_AVAILABLE");
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Sql.IsEmptyGuid(Security.USER_ID))
            {
                Response.Redirect("~/Webforms/client-login.aspx");
            }

            HostedSite = Sql.ToString(HttpContext.Current.Application["Config.hostedsite"]);

            string id = Request.QueryString["ID"].ToString();

            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select top 1                " + ControlChars.CrLf
                       + " FILENAME, FILE_MIME_TYPE, ATTACHMENT" + ControlChars.CrLf
                       + "  from vwATTACHMENTS_CONTENT" + ControlChars.CrLf
                       + " where 1 = 1                    " + ControlChars.CrLf;
                //Debug.Print(sSQL);
                using (IDbCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = sSQL;

                    Sql.AppendParameter(cmd, id.ToString(), "ATTACHMENT_ID");

                    cmd.CommandText += " order by DATE_ENTERED desc" + ControlChars.CrLf;

                    using (DbDataAdapter da = dbf.CreateDataAdapter())
                    {
                        ((IDbDataAdapter)da).SelectCommand = cmd;
                        using (DataTable dt = new DataTable())
                        {
                            da.Fill(dt);

                            if (dt.Rows.Count > 0)
                            {
                                foreach (DataRow r in dt.Rows)
                                {
                                    string name        = (string)r["FILENAME"];
                                    string contentType = (string)r["FILE_MIME_TYPE"];
                                    Byte[] data        = (Byte[])r["ATTACHMENT"];

                                    // Send the file to the browser
                                    Response.AddHeader("Content-type", contentType);
                                    Response.AddHeader("Content-Disposition", "attachment; filename=" + MakeValidFileName(name));
                                    Response.BinaryWrite(data);
                                    Response.Flush();
                                    Response.End();
                                }
                            }
                            else
                            {
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
        protected void BindGrid()
        {
            Guid gUSER_ID = Sql.ToGuid(lstUSERS.SelectedValue);

            if (Sql.IsEmptyGuid(gUSER_ID))
            {
                ctlAccessView.Visible = false;
                btnSelectRole.Visible = false;
                grdMain.Visible       = false;
                return;
            }
            ctlAccessView.USER_ID = gUSER_ID;
            ctlAccessView.Visible = true;
            btnSelectRole.Visible = true;
            grdMain.Visible       = true;

            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select *                 " + ControlChars.CrLf
                       + "  from vwUSERS_ACL_ROLES " + ControlChars.CrLf
                       + " where 1 = 1             " + ControlChars.CrLf;
                using (IDbCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = sSQL;
                    Sql.AppendParameter(cmd, gUSER_ID, "USER_ID");
#if DEBUG
                    Page.RegisterClientScriptBlock("vwUSER_ACL_ROLES", Sql.ClientScriptBlock(cmd));
#endif
                    try
                    {
                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;
                                // 05/03/2006 Paul.  Always bind, so that we don't have to redirect to show changes.
                                //if ( !IsPostBack )
                                {
                                    grdMain.SortColumn = "ROLE_NAME";
                                    grdMain.SortOrder  = "asc";
                                    grdMain.ApplySort();
                                    grdMain.DataBind();
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                        lblError.Text = ex.Message;
                    }
                }
            }
        }
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtFIRST_NAME.Text, 25, Sql.SqlFilterMode.StartsWith, "FIRST_NAME");
     Sql.AppendParameter(cmd, txtLAST_NAME.Text, 25, Sql.SqlFilterMode.StartsWith, "LAST_NAME");
     Sql.AppendParameter(cmd, txtDEPARTMENT.Text, 50, Sql.SqlFilterMode.StartsWith, "DEPARTMENT");
     Sql.AppendParameter(cmd, lstSTATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "STATUS");
 }
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtNAME.Text, 50, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtTYPE_NAME.Text, 50, Sql.SqlFilterMode.StartsWith, "TYPE_NAME");
     Sql.AppendParameter(cmd, txtCATEGORY_NAME.Text, 50, Sql.SqlFilterMode.StartsWith, "CATEGORY_NAME");
     Sql.AppendParameter(cmd, txtMANUFACTURER_NAME.Text, 50, Sql.SqlFilterMode.StartsWith, "MANUFACTURER_NAME");
 }
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtNAME.Text, 50, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtDISPLAY_NAME.Text, 2000, Sql.SqlFilterMode.StartsWith, "DISPLAY_NAME");
     Sql.AppendParameter(cmd, lstLANGUAGE.SelectedValue, 10, Sql.SqlFilterMode.Exact, "LANG");
     Sql.AppendParameter(cmd, lstMODULE_NAME.SelectedValue, 20, Sql.SqlFilterMode.Exact, "MODULE_NAME");
     Sql.AppendParameter(cmd, lstLIST_NAME.SelectedValue, 50, Sql.SqlFilterMode.Exact, "LIST_NAME");
 }
Exemple #7
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtDOCUMENT_NAME.Text, 255, Sql.SqlFilterMode.StartsWith, "DOCUMENT_NAME");
     Sql.AppendParameter(cmd, lstCATEGORY_ID.SelectedValue, 25, Sql.SqlFilterMode.Exact, "CATEGORY_ID");
     Sql.AppendParameter(cmd, lstSUBCATEGORY_ID.SelectedValue, 25, Sql.SqlFilterMode.Exact, "SUBCATEGORY_ID");
     Sql.AppendParameter(cmd, T10n.ToServerTime(Sql.ToDateTime(txtACTIVE_DATE.Text)), "ACTIVE_DATE");
     Sql.AppendParameter(cmd, T10n.ToServerTime(Sql.ToDateTime(txtEXP_DATE.Text)), "EXP_DATE");
 }
Exemple #8
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtNAME.Text, 50, Sql.SqlFilterMode.StartsWith, "NAME");
     if (chkCURRENT_USER_ONLY.Checked)
     {
         Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);
     }
 }
		private void Page_Load(object sender, System.EventArgs e)
		{
			Utils.SetPageTitle(Page, L10n.Term(m_sMODULE + ".LBL_LIST_FORM_TITLE"));
			// 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load. 
			this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "list") >= 0);
			if ( !this.Visible )
				return;

			try
			{
				DbProviderFactory dbf = DbProviderFactories.GetFactory();
				using ( IDbConnection con = dbf.CreateConnection() )
				{
					string sSQL;
					sSQL = "select *           " + ControlChars.CrLf
					     + "  from vwFEEDS_List" + ControlChars.CrLf
					     + " where 1 = 1       " + ControlChars.CrLf;
					using ( IDbCommand cmd = con.CreateCommand() )
					{
						cmd.CommandText = sSQL;
						int nACLACCESS = Security.GetUserAccess(m_sMODULE, "list");
						if ( nACLACCESS == ACL_ACCESS.OWNER )
							Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);
						ctlSearch.SqlSearchClause(cmd);
#if DEBUG
						Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
#endif
						using ( DbDataAdapter da = dbf.CreateDataAdapter() )
						{
							((IDbDataAdapter)da).SelectCommand = cmd;
							using ( DataTable dt = new DataTable() )
							{
								da.Fill(dt);
								vwMain = dt.DefaultView;
								grdMain.DataSource = vwMain ;
								if ( !IsPostBack )
								{
									grdMain.SortColumn = "TITLE";
									grdMain.SortOrder  = "asc"  ;
									grdMain.ApplySort();
									grdMain.DataBind();
								}
							}
						}
					}
				}
			}
			catch(Exception ex)
			{
				SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
				lblError.Text = ex.Message;
			}
			if ( !IsPostBack )
			{
				// 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages. 
				//Page.DataBind();
			}
		}
Exemple #10
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, Sql.ToInteger(txtCASE_NUMBER.Text), "CASE_NUMBER", Sql.IsEmptyString(txtCASE_NUMBER.Text));
     Sql.AppendParameter(cmd, txtNAME.Text, 255, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtACCOUNT_NAME.Text, 100, Sql.SqlFilterMode.StartsWith, "ACCOUNT_NAME");
     Sql.AppendParameter(cmd, lstSTATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "STATUS");
     Sql.AppendParameter(cmd, lstPRIORITY.SelectedValue, 25, Sql.SqlFilterMode.Exact, "PRIORITY");
     Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID");
 }
Exemple #11
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtNAME.Text, 50, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtMFT_PART_NUM.Text, 50, Sql.SqlFilterMode.StartsWith, "MFT_PART_NUM");
     if (!Sql.IsEmptyGuid(lstCATEGORY.SelectedValue))
     {
         Sql.AppendParameter(cmd, Sql.ToGuid(lstCATEGORY.SelectedValue), "CATEGORY_ID");
     }
 }
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtNAME.Text, 255, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, lstSTATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "STATUS");
     Sql.AppendParameter(cmd, lstCAMPAIGN_TYPE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "CAMPAIGN_TYPE");
     // 07/09/2006 Paul.  Date is no longer converted in the DatePicker control, so convert it here to server time.
     Sql.AppendParameter(cmd, T10n.ToServerTime(ctlSTART_DATE.Value), "START_DATE");
     Sql.AppendParameter(cmd, T10n.ToServerTime(ctlEND_DATE.Value), "END_DATE");
     Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID");
 }
Exemple #13
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, Sql.ToInteger(txtQUOTE_NUM.Text), "QUOTE_NUM", Sql.IsEmptyString(txtQUOTE_NUM.Text));
     Sql.AppendParameter(cmd, txtNAME.Text, 50, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtACCOUNT_NAME.Text, 150, Sql.SqlFilterMode.StartsWith, "ACCOUNT_NAME");
     if (chkCURRENT_USER_ONLY.Checked)
     {
         Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);
     }
 }
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtNAME.Text, 50, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtCONTACT_NAME.Text, 100, Sql.SqlFilterMode.StartsWith, "CONTACT_NAME");
     if (chkCURRENT_USER_ONLY.Checked)
     {
         //cmd.CommandText += "   and ASSIGNED_USER_ID = @ASSIGNED_USER_ID" + ControlChars.CrLf;
         //cmd.Parameters.Add("@ASSIGNED_USER_ID", SqlDbType.UniqueIdentifier, 16).Value = UserID;
     }
 }
Exemple #15
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtNAME.Text, 255, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtACCOUNT_NAME.Text, 100, Sql.SqlFilterMode.StartsWith, "ACCOUNT_NAME");
     Sql.AppendParameter(cmd, lstSTATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "STATUS");
     if (chkCURRENT_USER_ONLY.Checked)
     {
         Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);
     }
 }
Exemple #16
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtFIRST_NAME.Text, 25, Sql.SqlFilterMode.StartsWith, "FIRST_NAME");
     Sql.AppendParameter(cmd, txtLAST_NAME.Text, 25, Sql.SqlFilterMode.StartsWith, "LAST_NAME");
     Sql.AppendParameter(cmd, lstLEAD_SOURCE.SelectedValue, 100, Sql.SqlFilterMode.Exact, "LEAD_SOURCE");
     if (chkCURRENT_USER_ONLY.Checked)
     {
         Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);
     }
 }
        public Invoice GetInvoiceByName(Guid gCURRENCY_ID, string sNAME)
        {
            Invoice item = new Invoice();

            //try
            {
                if (Security.USER_ID == Guid.Empty)
                {
                    throw(new Exception("Authentication required"));
                }

                SplendidCRM.DbProviderFactory dbf = SplendidCRM.DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    con.Open();
                    string sSQL;
                    // 04/13/2007 Paul.  Use LIKE clause so that the user can abbreviate Names.
                    sSQL = "select *         " + ControlChars.CrLf
                           + "  from vwINVOICES" + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;
                        Security.Filter(cmd, "Invoices", "list");
                        Sql.AppendParameter(cmd, sNAME, Sql.SqlFilterMode.StartsWith, "NAME");
                        using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                        {
                            if (rdr.Read())
                            {
                                item.ID                  = Sql.ToGuid(rdr["ID"]);
                                item.NAME                = Sql.ToString(rdr["NAME"]);
                                item.AMOUNT_DUE          = Sql.ToDecimal(rdr["AMOUNT_DUE"]);
                                item.AMOUNT_DUE_USDOLLAR = Sql.ToDecimal(rdr["AMOUNT_DUE_USDOLLAR"]);
                                // 03/31/2007 Paul.  The price of the product may not be in the same currency as the order form.
                                // Make sure to convert to the specified currency.
                                if (gCURRENCY_ID != Sql.ToGuid(rdr["CURRENCY_ID"]))
                                {
                                    Currency C10n = Currency.CreateCurrency(gCURRENCY_ID);
                                    item.AMOUNT_DUE = C10n.ToCurrency(item.AMOUNT_DUE_USDOLLAR);
                                }
                            }
                        }
                    }
                }
                if (Sql.IsEmptyGuid(item.ID))
                {
                    throw(new Exception("Item not found"));
                }
            }
            //catch
            {
                // 02/04/2007 Paul.  Don't catch the exception.
                // It is a web service, so the exception will be handled properly by the AJAX framework.
            }
            return(item);
        }
Exemple #18
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     // 07/18/2006 Paul.  SqlFilterMode.Contains behavior has be deprecated. It is now the same as SqlFilterMode.StartsWith.
     Sql.AppendParameter(cmd, txtNAME.Text, 255, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtACCOUNT_NAME.Text, 100, Sql.SqlFilterMode.StartsWith, "ACCOUNT_NAME");
     Sql.AppendParameter(cmd, lstSTATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "STATUS");
     // 07/09/2006 Paul.  Date is no longer converted in the DatePicker control, so convert it here to server time.
     Sql.AppendParameter(cmd, T10n.ToServerTime(ctlSTART_DATE.Value), "START_DATE");
     Sql.AppendParameter(cmd, T10n.ToServerTime(ctlEND_DATE.Value), "END_DATE");
     Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID");
 }
Exemple #19
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, Sql.ToInteger(txtBUG_NUMBER.Text), "BUG_NUMBER", Sql.IsEmptyString(txtBUG_NUMBER.Text));
     Sql.AppendParameter(cmd, txtNAME.Text, 255, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, lstRESOLUTION.SelectedValue, 25, Sql.SqlFilterMode.Exact, "RESOLUTION");
     Sql.AppendParameter(cmd, lstRELEASE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "RELEASE");
     Sql.AppendParameter(cmd, lstSTATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "STATUS");
     Sql.AppendParameter(cmd, lstTYPE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "TYPE");
     Sql.AppendParameter(cmd, lstPRIORITY.SelectedValue, 25, Sql.SqlFilterMode.Exact, "PRIORITY");
     Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID");
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            gID = Sql.ToGuid(Request["ID"]);
            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select *                  " + ControlChars.CrLf
                       + "  from vwQUOTES_LINE_ITEMS" + ControlChars.CrLf
                       + " where 1 = 1              " + ControlChars.CrLf;
                using (IDbCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = sSQL;
                    Sql.AppendParameter(cmd, gID, "QUOTE_ID", false);
                    cmd.CommandText += " order by POSITION asc" + ControlChars.CrLf;

                    if (bDebug)
                    {
                        RegisterClientScriptBlock("vwQUOTES_LINE_ITEMS", Sql.ClientScriptBlock(cmd));
                    }

                    try
                    {
                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;
                                // 09/05/2005 Paul. LinkButton controls will not fire an event unless the the grid is bound.
                                //if ( !IsPostBack )
                                {
                                    grdMain.DataBind();
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                        lblError.Text = ex.Message;
                    }
                }
            }
            if (!IsPostBack)
            {
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();
            }
        }
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtNAME.Text, 150, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtCITY.Text, 100, Sql.SqlFilterMode.StartsWith, "CITY");
     Sql.AppendParameter(cmd, txtWEBSITE.Text, 255, Sql.SqlFilterMode.StartsWith, "WEBSITE");
     // 07/18/2006 Paul.  SqlFilterMode.Contains behavior has be deprecated. It is now the same as SqlFilterMode.StartsWith.
     Sql.AppendParameter(cmd, txtPHONE.Text, 25, Sql.SqlFilterMode.StartsWith, "PHONE");
     if (chkCURRENT_USER_ONLY.Checked)
     {
         Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);
     }
 }
        protected void btnProductChanged_Clicked(object sender, System.EventArgs e)
        {
            try
            {
                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    string sSQL;
                    sSQL = "select *                       " + ControlChars.CrLf
                           + "  from vwPRODUCTS_FromTemplate " + ControlChars.CrLf
                           + " where 1 = 1                   " + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;
                        Guid gPRODUCT_TEMPLATE_ID = new DynamicControl(this, "PRODUCT_TEMPLATE_ID").ID;
                        Sql.AppendParameter(cmd, gPRODUCT_TEMPLATE_ID, "ID", false);
                        con.Open();

                        if (bDebug)
                        {
                            RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                        }

                        using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                        {
                            if (rdr.Read())
                            {
                                ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]);
                                SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                                Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title);
                                ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title;

                                SplendidDynamic.SetEditViewFields(this, m_sMODULE + ".EditView", rdr, GetL10n(), GetT10n());
                                SplendidDynamic.SetEditViewFields(this, m_sMODULE + ".CostView", rdr, GetL10n(), GetT10n());
                                SplendidDynamic.SetEditViewFields(this, m_sMODULE + ".MftView", rdr, GetL10n(), GetT10n());
                                // 07/05/2006 Paul.  The Product Name should be editable.
                                TextBox txtNAME = FindControl("NAME") as TextBox;
                                if (txtNAME != null)
                                {
                                    txtNAME.ReadOnly = false;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
Exemple #23
0
        public static Stack FilterByACL_Stack(string sMODULE_NAME, string sACCESS_TYPE, string[] arrID, string sTABLE_NAME)
        {
            Stack         stk        = new Stack();
            StringBuilder sb         = new StringBuilder();
            int           nACLACCESS = Security.GetUserAccess(sMODULE_NAME, sACCESS_TYPE);

            if (nACLACCESS >= 0 && arrID.Length > 0)
            {
                if (nACLACCESS == ACL_ACCESS.OWNER)
                {
                    DbProviderFactory dbf = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        // 09/26/2006 Paul.  The connection needed to be opened.
                        con.Open();
                        string sSQL;
                        sSQL = "select ID              " + ControlChars.CrLf
                               + "  from vw" + sTABLE_NAME + ControlChars.CrLf
                               + " where 1 = 1           " + ControlChars.CrLf;
                        using (IDbCommand cmd = con.CreateCommand())
                        {
                            cmd.CommandText = sSQL;
                            Sql.AppendGuids(cmd, arrID, "ID");
                            Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);
                            using (IDataReader rdr = cmd.ExecuteReader())
                            {
                                while (rdr.Read())
                                {
                                    stk.Push(Sql.ToString(rdr["ID"]));
                                }
                            }
                        }
                    }
                    if (stk.Count == 0)
                    {
                        L10N L10n = HttpContext.Current.Items["L10n"] as L10N;
                        throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS")));
                    }
                }
                else
                {
                    foreach (string sID in arrID)
                    {
                        if (sID.Length > 0)
                        {
                            stk.Push(sID);
                        }
                    }
                }
            }
            return(stk);
        }
        protected void Bind(bool bBind)
        {
            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select *             " + ControlChars.CrLf
                       + "  from vwCALLS_MyList" + ControlChars.CrLf;
                using (IDbCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = sSQL;
                    // 11/24/2006 Paul.  Use new Security.Filter() function to apply Team and ACL security rules.
                    Security.Filter(cmd, m_sMODULE, "list");
                    Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);

                    if (bDebug)
                    {
                        RegisterClientScriptBlock("vwCALLS_List", Sql.ClientScriptBlock(cmd));
                    }

                    try
                    {
                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                vwMain             = dt.DefaultView;
                                grdMain.DataSource = vwMain;
                                if (bBind)
                                {
                                    grdMain.SortColumn = "DATE_START";
                                    grdMain.SortOrder  = "asc";
                                    grdMain.ApplySort();
                                }
                                // 09/15/2005 Paul. We must always bind, otherwise a Dashboard refresh will display the grid with empty rows.
                                grdMain.DataBind();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                        lblError.Text = ex.Message;
                    }
                }
            }
        }
Exemple #25
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, Sql.ToInteger(txtQUOTE_NUM.Text), "QUOTE_NUM", Sql.IsEmptyString(txtQUOTE_NUM.Text));
     Sql.AppendParameter(cmd, Sql.ToDecimal(txtTOTAL.Text), "TOTAL", Sql.IsEmptyString(txtTOTAL.Text));
     // 07/18/2006 Paul.  SqlFilterMode.Contains behavior has be deprecated. It is now the same as SqlFilterMode.StartsWith.
     Sql.AppendParameter(cmd, txtNAME.Text, 50, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, txtACCOUNT_NAME.Text, 150, Sql.SqlFilterMode.StartsWith, new string[] { "SHIPPING_ACCOUNT_NAME", "BILLING_ACCOUNT_NAME" });
     Sql.AppendParameter(cmd, txtNEXT_STEP.Text, 255, Sql.SqlFilterMode.StartsWith, "NEXT_STEP");
     Sql.AppendParameter(cmd, lstQUOTE_TYPE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "QUOTE_TYPE");
     Sql.AppendParameter(cmd, lstLEAD_SOURCE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "LEAD_SOURCE");
     Sql.AppendParameter(cmd, lstQUOTE_STAGE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "QUOTE_STAGE");
     // 07/09/2006 Paul.  Date is no longer converted in the DatePicker control, so convert it here to server time.
     Sql.AppendParameter(cmd, T10n.ToServerTime(ctlDATE_QUOTE_EXPECTED_CLOSED.Value), "DATE_QUOTE_EXPECTED_CLOSED");
     Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID");
 }
Exemple #26
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     // 09/13/2006 Paul.  Change FIRST_NAME to NAME.
     Sql.AppendParameter(cmd, txtNAME.Text, 25, Sql.SqlFilterMode.StartsWith, "NAME");
     Sql.AppendParameter(cmd, Sql.ToDecimal(txtAMOUNT.Text), "AMOUNT", Sql.IsEmptyString(txtAMOUNT.Text));
     Sql.AppendParameter(cmd, T10n.ToServerTime(Sql.ToDateTime(txtDATE_CLOSED.Text)), "DATE_CLOSED");
     Sql.AppendParameter(cmd, txtNEXT_STEP.Text, 25, Sql.SqlFilterMode.StartsWith, "NEXT_STEP");
     Sql.AppendParameter(cmd, txtACCOUNT_NAME.Text, 150, Sql.SqlFilterMode.StartsWith, "ACCOUNT_NAME");
     // 09/01/2006 Paul.  Add PROBABILITY.
     Sql.AppendParameter(cmd, Sql.ToFloat(txtPROBABILITY.Text), "PROBABILITY", Sql.IsEmptyString(txtPROBABILITY.Text));
     Sql.AppendParameter(cmd, lstOPPORTUNITY_TYPE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "OPPORTUNITY_TYPE");
     Sql.AppendParameter(cmd, lstLEAD_SOURCE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "LEAD_SOURCE");
     // 09/01/2006 Paul.  Change STATUS to SALES_STAGE.
     Sql.AppendParameter(cmd, lstSALES_STAGE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "SALES_STAGE");
     Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID");
 }
        public static string FilterByACL(string sMODULE_NAME, string sACCESS_TYPE, string[] arrID, string sTABLE_NAME)
        {
            StringBuilder sb         = new StringBuilder();
            int           nACLACCESS = Security.GetUserAccess(sMODULE_NAME, sACCESS_TYPE);

            if (nACLACCESS >= 0 && arrID.Length > 0)
            {
                if (nACLACCESS == ACL_ACCESS.OWNER)
                {
                    DbProviderFactory dbf = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        string sSQL;
                        sSQL = "select ID              " + ControlChars.CrLf
                               + "  from vw" + sTABLE_NAME + ControlChars.CrLf
                               + " where 1 = 1           " + ControlChars.CrLf;
                        using (IDbCommand cmd = con.CreateCommand())
                        {
                            cmd.CommandText = sSQL;
                            Sql.AppendGuids(cmd, arrID, "ID");
                            Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false);
                            using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                            {
                                while (rdr.Read())
                                {
                                    if (sb.Length > 0)
                                    {
                                        sb.Append(",");
                                    }
                                    sb.Append(Sql.ToString(rdr["ID"]));
                                }
                            }
                        }
                    }
                    if (sb.Length == 0)
                    {
                        L10N L10n = HttpContext.Current.Items["L10n"] as L10N;
                        throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS")));
                    }
                }
                else
                {
                    return(String.Join(",", arrID));
                }
            }
            return(sb.ToString());
        }
Exemple #28
0
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtFIRST_NAME.Text, 25, Sql.SqlFilterMode.StartsWith, "FIRST_NAME");
     // 07/18/2006 Paul.  SqlFilterMode.Contains behavior has be deprecated. It is now the same as SqlFilterMode.StartsWith.
     Sql.AppendParameter(cmd, txtPHONE.Text, 25, Sql.SqlFilterMode.StartsWith, new string[] { "PHONE_HOME", "PHONE_MOBILE", "PHONE_WORK", "PHONE_OTHER", "PHONE_FAX", "ASSISTANT_PHONE" });
     Sql.AppendParameter(cmd, txtLAST_NAME.Text, 25, Sql.SqlFilterMode.StartsWith, "LAST_NAME");
     Sql.AppendParameter(cmd, txtEMAIL.Text, 100, Sql.SqlFilterMode.StartsWith, new string[] { "EMAIL1", "EMAIL2" });
     Sql.AppendParameter(cmd, txtASSISTANT.Text, 75, Sql.SqlFilterMode.StartsWith, "ASSISTANT");
     Sql.AppendParameter(cmd, txtADDRESS_STREET.Text, 150, Sql.SqlFilterMode.StartsWith, new string[] { "PRIMARY_ADDRESS_STREET", "ALT_ADDRESS_STREET" });
     Sql.AppendParameter(cmd, txtADDRESS_CITY.Text, 100, Sql.SqlFilterMode.StartsWith, new string[] { "PRIMARY_ADDRESS_CITY", "ALT_ADDRESS_CITY" });
     Sql.AppendParameter(cmd, txtADDRESS_STATE.Text, 100, Sql.SqlFilterMode.StartsWith, new string[] { "PRIMARY_ADDRESS_STATE", "ALT_ADDRESS_STATE" });
     Sql.AppendParameter(cmd, txtADDRESS_POSTALCODE.Text, 20, Sql.SqlFilterMode.StartsWith, new string[] { "PRIMARY_ADDRESS_POSTALCODE", "ALT_ADDRESS_POSTALCODE" });
     Sql.AppendParameter(cmd, txtADDRESS_COUNTRY.Text, 100, Sql.SqlFilterMode.StartsWith, new string[] { "PRIMARY_ADDRESS_COUNTRY", "ALT_ADDRESS_COUNTRY" });
     Sql.AppendParameter(cmd, chkDO_NOT_CALL.Checked, "DO_NOT_CALL");
     Sql.AppendParameter(cmd, chkEMAIL_OPT_OUT.Checked, "EMAIL_OPT_OUT");
     Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID");
 }
 public override void SqlSearchClause(IDbCommand cmd)
 {
     Sql.AppendParameter(cmd, txtFIRST_NAME.Text, 30, Sql.SqlFilterMode.StartsWith, "FIRST_NAME");
     Sql.AppendParameter(cmd, txtLAST_NAME.Text, 30, Sql.SqlFilterMode.StartsWith, "LAST_NAME");
     Sql.AppendParameter(cmd, txtUSER_NAME.Text, 20, Sql.SqlFilterMode.StartsWith, "USER_NAME");
     // 07/18/2006 Paul.  SqlFilterMode.Contains behavior has be deprecated. It is now the same as SqlFilterMode.StartsWith.
     Sql.AppendParameter(cmd, txtPHONE.Text, 50, Sql.SqlFilterMode.StartsWith, new string[] { "PHONE_HOME", "PHONE_MOBILE", "PHONE_WORK", "PHONE_OTHER", "PHONE_FAX" });
     Sql.AppendParameter(cmd, txtEMAIL.Text, 100, Sql.SqlFilterMode.StartsWith, new string[] { "EMAIL1", "EMAIL2" });
     Sql.AppendParameter(cmd, txtTITLE.Text, 50, Sql.SqlFilterMode.StartsWith, "TITLE");
     Sql.AppendParameter(cmd, txtDEPARTMENT.Text, 75, Sql.SqlFilterMode.StartsWith, "DEPARTMENT");
     Sql.AppendParameter(cmd, txtADDRESS_STREET.Text, 150, Sql.SqlFilterMode.StartsWith, "ADDRESS_STREET");
     Sql.AppendParameter(cmd, txtADDRESS_CITY.Text, 100, Sql.SqlFilterMode.StartsWith, "ADDRESS_CITY");
     Sql.AppendParameter(cmd, txtADDRESS_STATE.Text, 100, Sql.SqlFilterMode.StartsWith, "ADDRESS_STATE");
     Sql.AppendParameter(cmd, txtADDRESS_POSTALCODE.Text, 20, Sql.SqlFilterMode.StartsWith, "ADDRESS_POSTALCODE");
     Sql.AppendParameter(cmd, txtADDRESS_COUNTRY.Text, 100, Sql.SqlFilterMode.StartsWith, "ADDRESS_COUNTRY");
     Sql.AppendParameter(cmd, lstEMPLOYEE_STATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "EMPLOYEE_STATUS");
 }
        public string[] ItemNumberList(string prefixText, int count)
        {
            string[] arrItems = new string[0];
            try
            {
                if (Security.USER_ID == Guid.Empty)
                {
                    throw(new Exception("Authentication required"));
                }

                SplendidCRM.DbProviderFactory dbf = SplendidCRM.DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    string sSQL;
                    // 03/29/2007 Paul.  Use LIKE clause so that the user can abbreviate unique part numbers.
                    sSQL = "select MFT_PART_NUM     " + ControlChars.CrLf
                           + "  from vwPRODUCT_CATALOG" + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;
                        Security.Filter(cmd, "ProductTemplates", "list");
                        Sql.AppendParameter(cmd, prefixText, Sql.SqlFilterMode.StartsWith, "MFT_PART_NUM");
                        sSQL += " order by MFT_PART_NUM" + ControlChars.CrLf;
                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(0, count, dt);
                                arrItems = new string[dt.Rows.Count];
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    arrItems[i] = Sql.ToString(dt.Rows[i]["MFT_PART_NUM"]);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            return(arrItems);
        }