Example #1
0
    private bool CreateCustomTableItem(string Desc, int Qty)
    {
        // Creates new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(MembershipContext.AuthenticatedUser);

        // Prepares the parameters
        string customTableClassName = "customtable.customBundle";

        // Checks if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);

        if (customTable != null)
        {
            // Creates new custom table item
            CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName, customTableProvider);

            // Sets the ItemText field value
            newCustomTableItem.SetValue("Quantity", Qty);
            newCustomTableItem.SetValue("Description", Desc);
            newCustomTableItem.SetValue("Enabled", true);
            // Inserts the custom table item into database
            newCustomTableItem.Insert();

            return(true);
        }

        return(false);
    }
Example #2
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "add")
        {
            // Add itemId in customtable_shippingextension.shippingoptionid

            // Creates new Custom table item provider
            CustomTableItemProvider customTableProvider = new CustomTableItemProvider(MembershipContext.AuthenticatedUser);

            // Prepares the parameters
            string customTableClassName = "customtable.shippingextension";

            // Checks if Custom table exists
            DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);
            if (customTable != null)
            {
                // Creates new custom table item
                CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName, customTableProvider);

                // Sets the ItemText field value
                newCustomTableItem.SetValue("ShippingOptionId", actionArgument.ToString());
                newCustomTableItem.SetValue("LocalContact", string.Empty);
                newCustomTableItem.SetValue("Enabled", true);
                newCustomTableItem.SetValue("ProcessingMode", 0);

                // Inserts the custom table item into database
                newCustomTableItem.Insert();
            }
            //Response.Redirect("ShippingExtension_List.aspx");
            Response.Redirect(Request.Url.ToString());
        }
    }
Example #3
0
        public void InsertCampaignOrdersInProgress(int campaignID)
        {
            DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);

            if (customTable != null)
            {
                CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);
                newCustomTableItem.SetValue("CampaignID", campaignID);
                newCustomTableItem.SetValue("IsCampaignOrdersInProgress", true);
                newCustomTableItem.SetValue("IsCampaignOrdersFailed", false);
                newCustomTableItem.Insert();
            }
        }
Example #4
0
    /// <summary>
    /// Creates custom table item. Called when the "Create item" button is pressed.
    /// </summary>
    private bool CreateCustomTableItem()
    {
        // Create new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);

        // Prepare the parameters
        string customTableClassName = "customtable.sampletable";

        // Check if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);

        if (customTable != null)
        {
            // Create new custom table item
            CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName, customTableProvider);

            // Set the ItemText field value
            newCustomTableItem.SetValue("ItemText", "New text");

            // Insert the custom table item into database
            newCustomTableItem.Insert();

            return(true);
        }

        return(false);
    }
Example #5
0
    /// <summary>
    /// Creates custom table item. Called when the "Create item" button is pressed.
    /// </summary>
    private bool CreateCustomTableItem()
    {
        // Create new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);

        // Prepare the parameters
        string customTableClassName = "customtable.sampletable";

        // Check if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);
        if (customTable != null)
        {
            // Create new custom table item
            CustomTableItem newCustomTableItem = new CustomTableItem(customTableClassName, customTableProvider);

            // Set the ItemText field value
            newCustomTableItem.SetValue("ItemText", "New text");

            // Insert the custom table item into database
            newCustomTableItem.Insert();

            return true;
        }

        return false;
    }
Example #6
0
        protected void ProcessCategory(int productNodeId, string categoryPath)
        {
            if (!string.IsNullOrEmpty(categoryPath))
            {
                var categoryItem = FindProductCategory(categoryPath);
                if (categoryItem != null)
                {
                    RelationshipInfoProvider.AddRelationship(productNodeId, categoryItem.NodeID,
                                                             productCategoryProductRelationshipID);
                }
                // if product detail or product category are null log error and add to error tracker (add error tracking custom table)fields, product detail name, product category name and explanation of what's wrong
                else
                {
                    // Prepares the code name (class name) of the custom table to which the data record will be added
                    string customTableClassName = "PbcLinear.ProcessCategoryErrors";

                    // Gets the custom table
                    DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
                    if (customTable != null)
                    {
                        // Creates a new custom table item
                        CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);

                        // Sets the values for the fields of the custom table (ItemText in this case)
                        newCustomTableItem.SetValue("ProductNodeId", productNodeId);
                        newCustomTableItem.SetValue("CategoryPath", categoryPath);
                        newCustomTableItem.SetValue("Error", "categoryItem is null ");

                        if (productNodeId == 0)
                        {
                            var newError = newCustomTableItem.GetValue("Error") + " productNodeId is empty";
                            newCustomTableItem.SetValue("Error", newError);
                        }

                        if (!string.IsNullOrEmpty(categoryPath))
                        {
                            var newError = newCustomTableItem.GetValue("Error") + " categoryPath is empty";
                            newCustomTableItem.SetValue("Error", newError);
                        }

                        // Save the new custom table record into the database
                        newCustomTableItem.Insert();
                    }
                }
            }
        }
Example #7
0
        /// <summary>
        /// This method will save the allocated product w.r.t to User in custome tabel
        /// </summary>
        /// <param name="productID">The id of the product which user wants to Allocate</param>
        private void AllocateProductToUsers(int productID)
        {
            string        customTableClassName = "KDA.UserAllocatedProducts";
            DataClassInfo customTable          = DataClassInfoProvider.GetDataClassInfo(customTableClassName);

            if (customTable != null)
            {
                CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);
                foreach (AllocateProduct User in lstUsers)
                {
                    newCustomTableItem.SetValue("UserID", User.UserID);
                    newCustomTableItem.SetValue("ProductID", productID);
                    newCustomTableItem.SetValue("Quantity", User.Quantity);
                    newCustomTableItem.SetValue("EmailID", User.EmailID);
                    newCustomTableItem.Insert();
                }
            }
        }
Example #8
0
        public void AdjustUserRemainingBudget(string year, int userID, decimal adjustment)
        {
            CustomTableItem userBudgetDetails = CustomTableItemProvider.GetItems(CustomTableClassName).WhereEquals("UserID", userID).WhereEquals("Year", year).FirstOrDefault();

            if (userBudgetDetails != null)
            {
                userBudgetDetails.SetValue("UserRemainingBudget", userBudgetDetails.GetValue("UserRemainingBudget", default(decimal)) + (adjustment));
                userBudgetDetails.Update();
            }
        }
Example #9
0
 /// <summary>
 /// Update the Product allocation
 /// </summary>
 /// <param name="productID">The id of the product which user wants to Update</param>
 private void UpdateAllocateProduct(int productID)
 {
     try
     {
         string        customTableClassName = "KDA.UserAllocatedProducts";
         DataClassInfo customTable          = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
         if (customTable != null)
         {
             var customTableData = CustomTableItemProvider.GetItems(customTableClassName)
                                   .WhereStartsWith("ProductID", productID.ToString());
             foreach (CustomTableItem customitem in customTableData)
             {
                 int index = lstUsers.FindIndex(item => item.UserID == ValidationHelper.GetInteger(customitem.GetValue("UserID"), 0));
                 if (index > -1)
                 {
                     customitem.SetValue("Quantity", lstUsers[index].Quantity);
                     customitem.Update();
                     lstUsers.RemoveAt(index);
                 }
                 else
                 {
                     customitem.Delete();
                     lstUsers.RemoveAt(index);
                 }
             }
         }
         CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);
         foreach (AllocateProduct User in lstUsers)
         {
             newCustomTableItem.SetValue("UserID", User.UserID);
             newCustomTableItem.SetValue("ProductID", productID);
             newCustomTableItem.SetValue("Quantity", User.Quantity);
             newCustomTableItem.SetValue("EmailID", User.EmailID);
             newCustomTableItem.Insert();
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("Product allocation update", "EXCEPTION", ex);
     }
 }
Example #10
0
        public UserBudgetItem CreateUserBudgetWithYear(string year, int siteID, int userId)
        {
            DataClassInfo   customTable        = DataClassInfoProvider.GetDataClassInfo(CustomTableClassName);
            CustomTableItem newCustomTableItem = CustomTableItem.New(CustomTableClassName);

            if (customTable != null)
            {
                newCustomTableItem.SetValue("UserID", userId);
                newCustomTableItem.SetValue("Year", year);
                newCustomTableItem.SetValue("Budget", default(decimal));
                newCustomTableItem.SetValue("UserRemainingBudget", default(decimal));
                newCustomTableItem.SetValue("SiteID", siteID);
                newCustomTableItem.Insert();
                return(new UserBudgetItem()
                {
                    ItemID = newCustomTableItem.ItemID,
                    Budget = newCustomTableItem.GetValue("Budget", default(decimal)),
                    UserID = userId,
                    UserRemainingBudget = newCustomTableItem.GetValue("UserRemainingBudget", default(decimal)),
                    Year = year
                });
            }
            return(null);
        }
Example #11
0
    /// <summary>
    /// Gets and updates custom table item. Called when the "Get and update item" button is pressed.
    /// Expects the CreateCustomTableItem method to be run first.
    /// </summary>
    private bool GetAndUpdateCustomTableItem()
    {
        // Create new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);

        string customTableClassName = "customtable.sampletable";

        // Check if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);

        if (customTable != null)
        {
            // Prepare the parameters
            string where = "ItemText LIKE N'New text'";
            int    topN    = 1;
            string columns = "ItemID";

            // Get the data set according to the parameters
            DataSet dataSet = customTableProvider.GetItems(customTableClassName, where, null, topN, columns);

            if (!DataHelper.DataSourceIsEmpty(dataSet))
            {
                // Get the custom table item ID
                int itemID = ValidationHelper.GetInteger(dataSet.Tables[0].Rows[0][0], 0);

                // Get the custom table item
                CustomTableItem updateCustomTableItem = customTableProvider.GetItem(itemID, customTableClassName);

                if (updateCustomTableItem != null)
                {
                    string itemText = ValidationHelper.GetString(updateCustomTableItem.GetValue("ItemText"), "");

                    // Set new values
                    updateCustomTableItem.SetValue("ItemText", itemText.ToLowerCSafe());

                    // Save the changes
                    updateCustomTableItem.Update();

                    return(true);
                }
            }
        }

        return(false);
    }
Example #12
0
    /// <summary>
    /// Gets and bulk updates custom table items. Called when the "Get and bulk update items" button is pressed.
    /// Expects the CreateCustomTableItem method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateCustomTableItems()
    {
        // Create new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);

        string customTableClassName = "customtable.sampletable";

        // Check if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);

        if (customTable != null)
        {
            // Prepare the parameters

            string where = "ItemText LIKE N'New text%'";

            // Get the data
            DataSet customTableItems = customTableProvider.GetItems(customTableClassName, where, null);
            if (!DataHelper.DataSourceIsEmpty(customTableItems))
            {
                // Loop through the individual items
                foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows)
                {
                    // Create object from DataRow
                    CustomTableItem modifyCustomTableItem = CustomTableItem.New(customTableItemDr, customTableClassName);

                    string itemText = ValidationHelper.GetString(modifyCustomTableItem.GetValue("ItemText"), "");

                    // Set new values
                    modifyCustomTableItem.SetValue("ItemText", itemText.ToUpper());

                    // Save the changes
                    modifyCustomTableItem.Update();
                }

                return(true);
            }
        }

        return(false);
    }
        public void InsertIBTFAdjustmentRecord(IBTFAdjustment inboundAdjustment)
        {
            DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(IBTFAdjustmentCustomTableName);

            if (customTable != null)
            {
                CustomTableItem newCustomTableItem = CustomTableItem.New(IBTFAdjustmentCustomTableName);
                newCustomTableItem.SetValue("SKUID", inboundAdjustment.SKUID);
                newCustomTableItem.SetValue("UserID", inboundAdjustment.UserID);
                newCustomTableItem.SetValue("CampaignID", inboundAdjustment.CampaignID);
                newCustomTableItem.SetValue("OrderedQuantity", inboundAdjustment.OrderedQuantity);
                newCustomTableItem.SetValue("OrderedProductPrice", inboundAdjustment.OrderedProductPrice);
                newCustomTableItem.SetValue("SiteName", SiteContext.CurrentSiteName);
                newCustomTableItem.Insert();
            }
        }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "add")
        {
            CountryInfo country = CountryInfoProvider.GetCountryInfo(Convert.ToInt32(actionArgument));
            // Check if country can be added in the ShippingExtension
            if (CheckCountry(Convert.ToInt32(actionArgument)))
            {
                // Add itemId in customtable_shippingextension.shippingoptionid
                // Creates new Custom table item provider
                CustomTableItemProvider customTableProvider = new CustomTableItemProvider(MembershipContext.AuthenticatedUser);

                // Prepares the parameters
                string customTableClassName = "customtable.shippingextensioncountry";

                // Checks if Custom table exists
                DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);
                if (customTable != null)
                {
                    // Creates new custom table item
                    CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName, customTableProvider);

                    // Sets the ItemText field value
                    newCustomTableItem.SetValue("ShippingOptionId", shippingExtensionID.ToString());
                    newCustomTableItem.SetValue("ShippingCountryId", actionArgument.ToString());
                    newCustomTableItem.SetValue("ShippingBase", 0);
                    newCustomTableItem.SetValue("LocalContact", string.Empty);
                    newCustomTableItem.SetValue("Enabled", true);
                    newCustomTableItem.SetValue("ProcessingMode", 1);
                    newCustomTableItem.SetValue("UnitPrice", 0);
                    // Inserts the custom table item into database
                    newCustomTableItem.Insert();
                }
                //Response.Redirect(Request.Url.ToString());
                ShowInformation(string.Format("<b>{0}</b> added for <b>{1}</b>", country.CountryName, GetShippingOptionName(shippingExtensionID.ToString())));
            }
            else
            {
                ShowError(string.Format("<b>{0}</b> is already defined for <b>{1}</b>", country.CountryName, GetShippingOptionName(shippingExtensionID.ToString())));
            }
        }
    }
        public void EditPOSNumber(int posId, bool status)
        {
            string customTableClassName = "KDA.POSNumber";

            try
            {
                // Gets the custom table
                DataClassInfo brandTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
                if (brandTable != null)
                {
                    // Gets all data records from the POS table whose 'ItemId' field value equal to PosId
                    CustomTableItem customTableData = CustomTableItemProvider.GetItem(posId, customTableClassName);
                    if (customTableData != null)
                    {
                        customTableData.SetValue("Enable", ValidationHelper.GetBoolean(status, false));
                        customTableData.Update();
                    }
                }
            }
            catch (Exception ex)
            {
                EventLogProvider.LogInformation("CMSWebParts_Kadena_POS_POSForm", "GetBrands", ex.Message);
            }
        }
Example #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Uri ServiceUri = new Uri(SUri);
        PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);

        DataAccessLayer.Credentials = new NetworkCredential(UserName, Password);
        _webControlParameters       = DataAccessLayer.WebControlParameters.ToList();


        if (_webControlParameters.Count > 0)
        {
            foreach (var x  in _webControlParameters)
            {
                //

                string customTableClassName = "Sme.personifyPages";
                string where = "ParameterName='" + x.ParameterName + "'";

                // Check if Custom table 'Sme.CommiteesMembers' exists
                DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);


                CustomTableItem item = CustomTableItem.New("Sme.personifyPages");
                item.SetValue("ParameterValue", x.ParameterValue);
                item.SetValue("ParameterName", x.ParameterName);
                item.Insert();
                //DataSet customTableRecord = CustomTableItemProvider.GetItems(customTableClassName, where);

                //int ItemID = 0;
                // if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                //    {
                //        // Get the custom table item ID
                //        ItemID = ValidationHelper.GetInteger(customTableRecord.Tables[0].Rows[0][0], 0);
                //    }

                //if (customTable != null)
                //{
                //    if (ItemID == 0)
                //    {
                //        CustomTableItem item = CustomTableItem.New("Sme.CommiteesMembers");
                //        item.SetValue("ParameterValue", x.ParameterValue);
                //        item.SetValue(" ParameterName", x.ParameterName);
                //        item.Insert();
                //    }

                //    else
                //    {

                //        if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                //        {
                //            CustomTableItem updateItem = CustomTableItemProvider.GetItem(ItemID, customTableClassName);
                //            if (updateItem != null)
                //            {
                //                updateItem.SetValue("ParameterValue", x.ParameterValue);
                //                updateItem.SetValue(" ParameterName", x.ParameterName);

                //                updateItem.Update();
                //            }
                //        }
                //    }
                //}

                ///
                Response.Write(x.ParameterValue + "---" + x.ParameterName + "<br/>");
            }
        }
    }
Example #17
0
    /// <summary>
    /// Lấy mã định danh mới
    /// </summary>
    /// <param name="dataYear">Mã theo năm</param>
    /// <param name="dataTable">Tiếp đầu ngữ của bảng</param>
    /// <param name="dataLen">Chiều dài số tự tăng</param>
    /// <param name="dataTXT">Mô tả về mã định danh</param>
    /// <returns>Mã định danh</returns>
    public static string Fn_Get_MaDinhDanh(string dataYear, string dataTable, int dataLen, string dataTXT)
    {
        string maDinhDanh;
        string dataYY = string.IsNullOrEmpty(dataYear) ? DateTime.Now.Year.ToString().Substring(2, 2) : dataYear.Substring(2, 2);
        // Create new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);
        // Prepares the code name of the custom table
        string Code_MaLuuTru = "DX.MaLuuTru";
        // Check if Custom table exists
        DataClassInfo DX_MaLuuTru = DataClassInfoProvider.GetDataClass(Code_MaLuuTru);

        maDinhDanh = "19000001";
        if (DX_MaLuuTru != null)
        {
            // Prepare the parameters
            string where = string.Format("MaTXT = '{0}{1}'", dataTable, dataYY);
            // Get the data set according to the parameters
            DataSet dataSet = customTableProvider.GetItems(Code_MaLuuTru, where, null, 1, "ItemID");
            if (!DataHelper.DataSourceIsEmpty(dataSet))
            {
                // Get the custom table item ID
                int itemID = ValidationHelper.GetInteger(dataSet.Tables[0].Rows[0][0], 0);
                // Get the custom table item
                CustomTableItem DX_MaLuuTru_Item = customTableProvider.GetItem(itemID, Code_MaLuuTru);
                if (DX_MaLuuTru_Item != null)
                {
                    string maTXT = ValidationHelper.GetString(DX_MaLuuTru_Item.GetValue("MaTXT"), "");
                    int    maNUM = ValidationHelper.GetInteger(DX_MaLuuTru_Item.GetValue("MaNUM"), 0);
                    int    maLEN = ValidationHelper.GetInteger(DX_MaLuuTru_Item.GetValue("MaLEN"), 0);

                    // Set new values
                    DX_MaLuuTru_Item.SetValue("MaNUM", maNUM + 1);
                    // Save the changes
                    DX_MaLuuTru_Item.Update();

                    StringBuilder sb      = new StringBuilder();
                    string        newText = sb.Append('0', maLEN - maNUM.ToString().Length).ToString() + maNUM + 1;
                    maDinhDanh = maTXT + newText;
                }
            }
            else
            {
                // Create new custom table item
                CustomTableItem newItem = new CustomTableItem(Code_MaLuuTru, customTableProvider);

                // Set the ItemText field value
                newItem.SetValue("MaTXT", dataTable + dataYY);
                newItem.SetValue("maNUM", 1);
                newItem.SetValue("maLEN", dataLen);
                newItem.SetValue("ActiveNUM", true);
                newItem.SetValue("MoTaTXT", dataTXT);
                // Insert the custom table item into database
                newItem.Insert();

                StringBuilder sb      = new StringBuilder();
                string        newText = dataTable + dataYY + sb.Append('0', dataLen - 0.ToString().Length).ToString() + 1;
                maDinhDanh = newText;
            }
        }
        // Return
        return(maDinhDanh);
    }
Example #18
0
    public void LoadIndividualData(int pageFrom, int pageTo)
    {
        StringBuilder documentsAddedStatus = new StringBuilder();

        string Query = "select * from (select distinct MasterCustomerId,LabelName,ROW_NUMBER() over (ORDER BY MasterCustomerId) AS Number from dbo.Sme_CommiteesMaster) as com where Number>=" + pageFrom + "AND Number<=" + pageTo;

        var      queryToGetCommittees = new QueryParameters(Query, null, CMS.DataEngine.QueryTypeEnum.SQLQuery, false);
        DataSet  ds = ConnectionHelper.ExecuteQuery(queryToGetCommittees);  //ExecQuery(Query); //("pb.account_types.select_accounts", null, where, null);
        string   CommitteeMemberId            = string.Empty;
        DateTime BeginDate                    = new DateTime();
        string   CommitteeMasterCustomer      = string.Empty;
        string   CommitteeMemberLastFirstName = string.Empty;
        string   CommitteeSubCustomer         = string.Empty;
        DateTime EndDate                        = new DateTime();
        string   MemberAddressId                = string.Empty;
        string   MemberAddressTypeCodeString    = string.Empty;
        string   MemberMasterCustomer           = string.Empty;
        string   ParticipationStatusCodeString  = string.Empty;
        string   PositionCodeDescriptionDisplay = string.Empty;
        string   PositionCodeString             = string.Empty;
        string   VotingStatusCodeString         = string.Empty;
        string   CommitteeLabelName             = string.Empty;

        if (ds.Tables[0].Rows.Count > 0)
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Uri ServiceUri =
                    new Uri("http://smemitst.personifycloud.com/PersonifyDataServices/PersonifyDatasme.svc");
                PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
                DataAccessLayer.Credentials = new NetworkCredential("admin", "admin");
                var CommiteeMembers =
                    DataAccessLayer.CommitteeMembers.Where(p => p.CommitteeMasterCustomer == dr["MasterCustomerId"])
                    .Select(o => o)
                    .ToList();
                if (CommiteeMembers != null)
                {
                    foreach (var member in CommiteeMembers)
                    {
                        CommitteeMemberId            = member.CommitteeMemberId.ToString();
                        BeginDate                    = Convert.ToDateTime(member.BeginDate);
                        CommitteeMasterCustomer      = member.CommitteeMasterCustomer;
                        CommitteeMemberLastFirstName = member.CommitteeMemberLastFirstName;
                        CommitteeSubCustomer         = member.CommitteeSubCustomer.ToString();
                        MemberAddressId              = member.MemberAddressId.ToString();

                        MemberAddressTypeCodeString    = member.MemberAddressTypeCodeString;
                        MemberMasterCustomer           = member.MemberMasterCustomer;
                        ParticipationStatusCodeString  = member.ParticipationStatusCodeString;
                        PositionCodeDescriptionDisplay = member.PositionCodeDescriptionDisplay.ToString();


                        PositionCodeString     = member.PositionCodeString;
                        VotingStatusCodeString = member.VotingStatusCodeString.ToString();
                        CommitteeLabelName     = member.CommitteeLabelName;
                        EndDate = Convert.ToDateTime(member.EndDate);

                        string customTableClassName = "Sme.CommiteesMembers";
                        string where = "CommitteeMemberId='" + CommitteeMemberId + "' AND CommitteeMemberLastFirstName='" + CommitteeMemberLastFirstName.Replace("'", "''") + "'";

                        // Check if Custom table 'Sme.CommiteesMembers' exists
                        DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);

                        DataSet customTableRecord = CustomTableItemProvider.GetItems(customTableClassName, where);

                        int memberID = 0;

                        if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                        {
                            // Get the custom table item ID
                            memberID = ValidationHelper.GetInteger(customTableRecord.Tables[0].Rows[0][0], 0);
                        }


                        if (customTable != null)
                        {
                            if (memberID == 0)
                            {
                                if (EndDate >= DateTime.Now ||
                                    PositionCodeDescriptionDisplay.ToLower().Contains("president"))
                                {
                                    // Create new item for custom table with "Sme.CommiteesMembers" code name
                                    CustomTableItem item = CustomTableItem.New("Sme.CommiteesMembers");
                                    item.SetValue("CommitteeMemberId", CommitteeMemberId);
                                    item.SetValue("BeginDate", BeginDate);
                                    item.SetValue("CommitteeMasterCustomer", CommitteeMasterCustomer);
                                    item.SetValue("CommitteeMemberLastFirstName", CommitteeMemberLastFirstName.Replace("'", "''"));
                                    item.SetValue("CommitteeSubCustomer", CommitteeSubCustomer);

                                    item.SetValue("MemberAddressId", MemberAddressId);
                                    item.SetValue("MemberAddressTypeCodeString", MemberAddressTypeCodeString);
                                    item.SetValue("MemberMasterCustomer", MemberMasterCustomer);
                                    item.SetValue("ParticipationStatusCodeString", ParticipationStatusCodeString);
                                    item.SetValue("PositionCodeDescriptionDisplay", PositionCodeDescriptionDisplay);
                                    item.SetValue("PositionCodeString", PositionCodeString);

                                    item.SetValue("VotingStatusCodeString", VotingStatusCodeString);
                                    item.SetValue("CommitteeLabelName", CommitteeLabelName);
                                    item.SetValue("EndDate", EndDate);
                                    item.Insert();
                                }

                                /*documentsAddedStatus.Append(
                                 *  "Added CommitteeLabelName : " + CommitteeLabelName + " in the CommitteeMemberId: "
                                 + CommitteeMemberId + "at" + DateTime.Now + Environment.NewLine);*/
                            }
                            else
                            {
                                if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                                {
                                    // Get the custom table item
                                    CustomTableItem updateItem = CustomTableItemProvider.GetItem(memberID, customTableClassName);

                                    if (updateItem != null)
                                    {
                                        if (EndDate >= DateTime.Now ||
                                            PositionCodeDescriptionDisplay.ToLower().Contains("president"))
                                        {
                                            //updateItem.SetValue("CommitteeMemberId", CommitteeMemberId);
                                            updateItem.SetValue("BeginDate", BeginDate);
                                            updateItem.SetValue("CommitteeMasterCustomer", CommitteeMasterCustomer);
                                            updateItem.SetValue("CommitteeMemberLastFirstName", CommitteeMemberLastFirstName.Replace("'", "''"));
                                            updateItem.SetValue("CommitteeSubCustomer", CommitteeSubCustomer);

                                            updateItem.SetValue("MemberAddressId", MemberAddressId);
                                            updateItem.SetValue(
                                                "MemberAddressTypeCodeString",
                                                MemberAddressTypeCodeString);
                                            updateItem.SetValue("MemberMasterCustomer", MemberMasterCustomer);
                                            updateItem.SetValue(
                                                "ParticipationStatusCodeString",
                                                ParticipationStatusCodeString);
                                            updateItem.SetValue(
                                                "PositionCodeDescriptionDisplay",
                                                PositionCodeDescriptionDisplay);
                                            updateItem.SetValue("PositionCodeString", PositionCodeString);

                                            updateItem.SetValue("VotingStatusCodeString", VotingStatusCodeString);
                                            updateItem.SetValue("CommitteeLabelName", CommitteeLabelName);
                                            updateItem.SetValue("EndDate", EndDate);
                                            updateItem.Update();

                                            /*documentsAddedStatus.Append(
                                             * "Updated CommitteeLabelName : " + CommitteeLabelName + " in the CommitteeMemberId: "
                                             + CommitteeMemberId + "at" + DateTime.Now + Environment.NewLine);*/
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                /*string rootFolder = "CMSWebParts";
                 * string folderName = "SME";
                 * string fileName = "CommitteeMembersStatusLogged.txt";
                 * string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, rootFolder, folderName, fileName);
                 *
                 * using (StreamWriter writer = new StreamWriter(filePath, true))
                 * {
                 *  writer.WriteLine(documentsAddedStatus);
                 *  writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
                 *  writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
                 * }*/
            }
        }
    }
Example #19
0
    /// <summary>
    /// Gets and bulk updates custom table items. Called when the "Get and bulk update items" button is pressed.
    /// Expects the CreateCustomTableItem method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateCustomTableItems()
    {
        // Create new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);

        string customTableClassName = "customtable.sampletable";

        // Check if Custom table 'Sample table' exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);
        if (customTable != null)
        {
            // Prepare the parameters

            string where = "ItemText LIKE N'New text%'";

            // Get the data
            DataSet customTableItems = customTableProvider.GetItems(customTableClassName, where, null);
            if (!DataHelper.DataSourceIsEmpty(customTableItems))
            {
                // Loop through the individual items
                foreach (DataRow customTableItemDr in customTableItems.Tables[0].Rows)
                {
                    // Create object from DataRow
                    CustomTableItem modifyCustomTableItem = new CustomTableItem(customTableItemDr, customTableClassName);

                    string itemText = ValidationHelper.GetString(modifyCustomTableItem.GetValue("ItemText"), "");

                    // Set new values
                    modifyCustomTableItem.SetValue("ItemText", itemText.ToUpper());

                    // Save the changes
                    modifyCustomTableItem.Update();
                }

                return true;
            }
        }

        return false;
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Creates new Custom table item provider
        CustomTableItemProvider customTableProvider = new CustomTableItemProvider(MembershipContext.AuthenticatedUser);

        // Prepares the parameters
        string customTableClassName = "customtable.shippingextensionpricing";

        // Checks if Custom table exists
        DataClassInfo customTable = DataClassInfoProvider.GetDataClass(customTableClassName);

        if (customTable != null)
        {
            // VALIDATION RULES
            int     shippingUnitTo = -1, shippingUnitFrom = Convert.ToInt32(txtShippingUnitFrom.Text);
            decimal price = 0;



            if (!string.IsNullOrEmpty(txtShippingUnitTo.Text))
            {
                txtShippingUnitTo.Text = txtShippingUnitTo.Text.Trim();

                // Ensures integer value entered in txtShippingUnitTo
                try
                {
                    shippingUnitTo = Convert.ToInt32(txtShippingUnitTo.Text);
                }
                catch
                {
                    ShowError(string.Format("<b>{0}</b> is not valid for <u><b>Shipping unit to</b></u>", txtShippingUnitTo.Text));
                    return;
                }

                // Ensures txtShippingUnitTo > txtShippingUnitFrom
                if (shippingUnitTo <= shippingUnitFrom && shippingUnitTo != -1)
                {
                    ShowError(string.Format("<u><b>Shipping unit to</b></u> must be greater than {0}", txtShippingUnitFrom.Text));
                    return;
                }

                // Ensures price exists
                if (string.IsNullOrEmpty(txtPrice.Text.Trim()))
                {
                    ShowError("Price must be entered");
                    return;
                }
            }

            // Ensures decimal value entered in txtPrice if txtShippingUnitTo is filled
            try
            {
                price = Convert.ToDecimal(txtPrice.Text);
            }
            catch
            {
                if (!string.IsNullOrEmpty(txtShippingUnitTo.Text.Trim()))
                {
                    ShowError(string.Format("<u><b>Price</b></u> {0} is not valid", txtPrice.Text));
                    return;
                }
            }

            // Creates new custom table item
            CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName, customTableProvider);
            // Sets the ItemText field value
            newCustomTableItem.SetValue("ShippingExtensionCountryId", mShippingExtensionPricingID);
            newCustomTableItem.SetValue("ShippingUnitFrom", int.Parse(txtShippingUnitFrom.Text));
            newCustomTableItem.SetValue("ShippingUnitTo", shippingUnitTo);
            newCustomTableItem.SetValue("ShippingUnitPrice", price);

            // Inserts the custom table item into database
            newCustomTableItem.Insert();
        }
        Response.Redirect(string.Format("ShippingExtension_Edit_Pricing.aspx?ItemID={0}", mShippingExtensionPricingID.ToString()));
    }
Example #21
0
    private Boolean CreateCustomTableItem(DataClassInfo customTable, DataRow dr)
    {
        if (customTable != null)
        {
            // Creates new custom table item

            CustomTableItem newCustomTableItem = CustomTableItem.New(customTable.ClassName, _customTableProvider);



            // Sets the ItemText field value
            try
            {
                if (_customTable == null)
                {
                    _customTable = (Session["_customTable"] != null ? (DataSet)Session["_customTable"] : null);
                }
                int i = 0;
                if (_customTable != null)
                {
                    foreach (DataColumn column in _customTable.Tables[0].Columns)
                    {
                        if (column.ColumnName.LastIndexOf("Item") == -1)
                        {
                            string temp = "";
                            object aaa  = default_value(column.ColumnName, out temp);
                            aaa = (aaa != null ? aaa : null);
                            if (aaa != null)
                            {
                                object vl = null;

                                /*
                                 * if (default_value_int(column.ColumnName))
                                 * {
                                 *
                                 *   vl = double_parse(dr[aaa.ToString()].ToString().Trim().Replace("$", "").Replace(",", ""));
                                 * }
                                 * else
                                 * {
                                 *   if (column.ColumnName == "Views") vl = int_parse(dr[aaa.ToString()].ToString().Trim());
                                 *   else
                                 *       if (column.ColumnName == "Featured") vl = bool_parse(dr[aaa.ToString()].ToString().Trim());
                                 *   else
                                 *           if (column.ColumnName == "Model") vl = dr[aaa.ToString()].ToString().Trim().Split('"')[0];
                                 *           else
                                 *       vl = dr[aaa.ToString()].ToString().Trim();
                                 *
                                 *
                                 *
                                 * }
                                 */
                                try
                                {
                                    vl = type_field(dr[aaa.ToString()].ToString());
                                    if (vl != null)
                                    {
                                        newCustomTableItem.SetValue(column.ColumnName, vl);
                                    }
                                }
                                catch (Exception exx)
                                {
                                    Literal1.Text += "<p>- Column " + temp + " error:" + exx.Message + "</p>";
                                }
                            }
                        }
                    }

                    newCustomTableItem.Insert();
                    return(true);
                }
            }
            catch (Exception e)
            {
                Literal1.Text += e.Message + "<br>";
                return(false);
            }
        }


        return(false);
    }