Пример #1
0
 /// <summary>
 ///  This method will get all the allocated user
 /// </summary>
 /// <param name="ProductId"></param>
 private void BindEditProduct(int ProductId)
 {
     try
     {
         lstUsers = new List <AllocateProduct>();
         List <AllocateProduct> lstProduct  = new List <AllocateProduct>();
         string        customTableClassName = "KDA.UserAllocatedProducts";
         DataClassInfo customTable          = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
         if (customTable != null)
         {
             var customTableData = CustomTableItemProvider.GetItems(customTableClassName)
                                   .WhereStartsWith("ProductID", ProductId.ToString());
             foreach (CustomTableItem item in customTableData)
             {
                 AllocateProduct objProduct = new AllocateProduct();
                 objProduct.EmailID  = ValidationHelper.GetString(item.GetValue("EmailID"), string.Empty);
                 objProduct.UserName = UserInfoProvider.GetUserInfo(ValidationHelper.GetInteger(item.GetValue("UserID"), 0)).FullName;
                 objProduct.Quantity = ValidationHelper.GetInteger(item.GetValue("Quantity"), 0);
                 objProduct.UserID   = ValidationHelper.GetInteger(item.GetValue("UserID"), 0);
                 lstProduct.Add(objProduct);
             }
             lstUsers.AddRange(lstProduct);
         }
         RepSelectedUser.DataSource = lstProduct;
         RepSelectedUser.DataBind();
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("Product allocation update BindEdit", "EXCEPTION", ex);
     }
 }
Пример #2
0
        /// <summary>
        /// This method will get all the users and bind it to repeater
        /// </summary>
        /// <param name="pageIndex"></param>
        private void BindUsers(int pageIndex)
        {
            List <AllocateProduct> lstAllocatedProd = new List <AllocateProduct>();
            string customTableClassName             = "KDA.UserAllocatedProducts";
            var    users = UserInfoProvider.GetUsers().Columns("Email", "UserID", "FullName").OnSite(CurrentSite.SiteID).OrderBy("FullName")
                           .Skip(PageSize * (pageIndex - 1))
                           .Take(PageSize);

            foreach (UserInfo user in users)
            {
                AllocateProduct objProduct = new AllocateProduct();
                objProduct.EmailID  = user.Email;
                objProduct.UserID   = user.UserID;
                objProduct.UserName = user.FullName;
                objProduct.Quantity = CustomTableItemProvider.GetItems(customTableClassName)
                                      .WhereEquals("ProductID", productId).WhereEquals("UserID", user.UserID).FirstOrDefault()?.GetValue("Quantity", default(int)) ?? 0;
                if (lstUsers.FindIndex(item => item.UserID == user.UserID) > -1)
                {
                    objProduct.Selected = true;
                }
                lstAllocatedProd.Add(objProduct);
            }
            RepterDetails.DataSource = lstAllocatedProd;
            RepterDetails.DataBind();
            PopulatePager(UserInfoProvider.GetUsers().OnSite(CurrentSite.SiteID).Count(), pageIndex);
        }
Пример #3
0
 /// <summary>
 /// Handles the Click event of the Allocate product button click .
 /// </summary>
 protected void AllocateProduct_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (RepeaterItem ri in RepterDetails.Items)
         {
             CheckBox item_check = (CheckBox)ri.FindControl("chkAllocate");
             if (item_check.Checked)
             {
                 int index     = lstUsers.FindIndex(item => item.UserID == ValidationHelper.GetInteger(((Label)ri.FindControl("lblUserid")).Text, 0));
                 var userEmail = ValidationHelper.GetString(((Label)ri.FindControl("lblEmail")).Text, string.Empty);
                 if (index == -1)
                 {
                     AllocateProduct objAllocateProduct = new AllocateProduct();
                     objAllocateProduct.UserID   = ValidationHelper.GetInteger(((Label)ri.FindControl("lblUserid")).Text, 0);
                     objAllocateProduct.UserName = ValidationHelper.GetString(((Label)ri.FindControl("lblUserName")).Text, string.Empty);
                     objAllocateProduct.EmailID  = ValidationHelper.GetString(((Label)ri.FindControl("lblEmail")).Text, string.Empty);
                     objAllocateProduct.Quantity = ValidationHelper.GetInteger(((TextBox)ri.FindControl("txtAllQuantity")).Text, 0);
                     lstUsers.Add(objAllocateProduct);
                 }
                 else
                 {
                     if (lstUsers.Count > 0)
                     {
                         lstUsers.Where(x => x.EmailID == userEmail).FirstOrDefault().Quantity = ValidationHelper.GetInteger(((TextBox)ri.FindControl("txtAllQuantity")).Text, 0);
                     }
                 }
             }
             else
             {
                 int index = lstUsers.FindIndex(item => item.UserID == ValidationHelper.GetInteger(((Label)ri.FindControl("lblUserid")).Text, 0));
                 if (index != -1)
                 {
                     lstUsers.RemoveAt(index);
                 }
             }
         }
         RepSelectedUser.DataSource = lstUsers;
         RepSelectedUser.DataBind();
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("CMSWebParts_Kadena_Add_inventory_Products_AllocateProduct", "AllocateProduct_Click", ex.Message);
     }
 }
Пример #4
0
 /// <summary>
 /// This method will get the users record when user click on pagination
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Changed(object sender, EventArgs e)
 {
     try
     {
         foreach (RepeaterItem ri in RepterDetails.Items)
         {
             CheckBox item_check = (CheckBox)ri.FindControl("chkAllocate");
             if (item_check.Checked)
             {
                 int index = lstUsers.FindIndex(item => item.UserID == ValidationHelper.GetInteger(((Label)ri.FindControl("lblUserid")).Text, 0));
                 if (index == -1)
                 {
                     AllocateProduct objAllocateProduct = new AllocateProduct();
                     objAllocateProduct.UserID   = ValidationHelper.GetInteger(((Label)ri.FindControl("lblUserid")).Text, 0);
                     objAllocateProduct.UserName = ValidationHelper.GetString(((Label)ri.FindControl("lblUserName")).Text, string.Empty);
                     objAllocateProduct.EmailID  = ValidationHelper.GetString(((Label)ri.FindControl("lblEmail")).Text, string.Empty);
                     objAllocateProduct.Quantity = ValidationHelper.GetInteger(((TextBox)ri.FindControl("txtAllQuantity")).Text, 0);
                     lstUsers.Add(objAllocateProduct);
                 }
             }
             else
             {
                 int index = lstUsers.FindIndex(item => item.UserID == ValidationHelper.GetInteger(((Label)ri.FindControl("lblUserid")).Text, 0));
                 if (index != -1)
                 {
                     lstUsers.RemoveAt(index);
                 }
             }
         }
         int pageIndex = int.Parse((sender as LinkButton).CommandArgument);
         this.BindUsers(pageIndex);
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("CMSWebParts_Kadena_Add_inventory_Products_Pagination", "Page_Changed", ex.Message);
     }
 }