コード例 #1
0
    protected void UpdateOpportunities(object sender, EventArgs e)
    {
        List <string>   updateList   = new List <string>();
        List <DateTime> estCloseList = new List <DateTime>();

        foreach (GridViewRow dr in UpdateOppsGrid.Rows)
        {
            CheckBox cb = (CheckBox)dr.Cells[0].FindControl("chkSelect");
            if (cb.Checked)
            {
                updateList.Add(cb.Attributes["Opportunityid"]);
                estCloseList.Add(Convert.ToDateTime(cb.Attributes["oppEstClose"]));
            }
        }

        if (updateList.Count != 0)
        {
            string idList = GetListOfIDs(updateList);

            if ((ddlUpdateOppDropDown.Text != GetLocalResourceObject("EstClose_rsc").ToString()) || (rdgEstClose.Checked))
            {
                string oppValue = GetUpdateFieldAndValue();
                if (!string.IsNullOrEmpty(oppValue))
                {
                    string SQL = "UPDATE OPPORTUNITY SET " + oppValue + " WHERE OPPORTUNITYID IN (" + idList + ")";

                    Sage.Platform.Data.IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Data.IDataService>();
                    using (new SparseQueryScope())
                        using (var conn = service.GetOpenConnection())
                        {
                            var cmd = conn.CreateCommand(SQL);
                            cmd.ExecuteNonQuery();
                        }
                }
            }
            else
            {
                List <string> oppEstValues = GetEstimatedCloseValues(estCloseList);

                IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get <IDataService>();

                using (new SparseQueryScope())
                {
                    for (int i = 0; i < oppEstValues.Count; i++)
                    {
                        string SQL = "UPDATE OPPORTUNITY SET ESTIMATEDCLOSE = '" + oppEstValues[i] + "' WHERE OPPORTUNITYID = '" + updateList[i] + "'";

                        using (var conn = service.GetOpenConnection())
                            using (var cmd = conn.CreateCommand(SQL))
                            {
                                cmd.ExecuteNonQuery();
                            }
                    }
                }
            }
        }
        LoadGrid();
    }
コード例 #2
0
    public static T GetField <T>(string Field, string Table, string Where)
    {
        string sql = string.Format("select {0} from {1} where {2}", Field, Table, (Where.Equals(string.Empty) ? "1=1" : Where));

        //get the DataService to get a connection string to the database
        Sage.Platform.Data.IDataService datasvc = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Data.IDataService>();
        using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(datasvc.GetConnectionString()))
        {
            conn.Open();
            using (OleDbCommand cmd = new OleDbCommand(sql, conn))
            {
                object fieldval = cmd.ExecuteScalar();
                return(fieldval == DBNull.Value ? default(T) : (T)fieldval);
            }
        }
    }
コード例 #3
0
    private static Boolean IsMember(string TeamName, string Type)
    {
        Boolean blnReturn = false; // Intialize False

        //Get Current user
        Sage.SalesLogix.Security.SLXUserService usersvc     = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Security.IUserService>();
        Sage.Entity.Interfaces.IUser            currentuser = usersvc.GetUser();
        // get the DataService to get a connection string to the database
        if (currentuser.Id.ToString() == "ADMIN       ")

        {
            blnReturn = true;
        }

        string SQL = "";

        SQL  = "select accessid from secrights where seccodeid = ";
        SQL += " (select seccodeid from seccode where (seccodedesc = '" + TeamName + "') ";
        SQL += " and (seccodetype = '" + Type + "')) and (accessid = '" + currentuser.Id.ToString() + "')";

        Sage.Platform.Data.IDataService datasvc = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Data.IDataService>();
        using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(datasvc.GetConnectionString()))
        {
            conn.Open();
            using (System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(SQL, conn))
            {
                OleDbDataReader reader = cmd.ExecuteReader();
                //loop through the reader
                while (reader.Read())
                {
                    if (reader["accessid"].ToString() != string.Empty)
                    {
                        blnReturn = true;
                    }
                }
                reader.Close();
            }
        }
        return(blnReturn);
    }