protected void grdEntities_RowDrop(object sender, GridDragDropEventArgs e) { if (e.DestDataItem != null) { var UncachedSexyContent = SexyUncached; ContentGroupItem DestItem = UncachedSexyContent.TemplateContext.GetContentGroupItem(((int)e.DestDataItem.GetDataKeyValue("ID"))); ContentGroupItem Item = UncachedSexyContent.TemplateContext.GetContentGroupItem(((int)e.DraggedItems[0].GetDataKeyValue("ID"))); int DestinationSortOrder = DestItem.SortOrder; if (e.DropPosition == GridItemDropPosition.Below) { DestinationSortOrder++; } if (Item.SortOrder < DestinationSortOrder) { DestinationSortOrder--; } UncachedSexyContent.TemplateContext.ReorderContentGroupItem(Item, DestinationSortOrder, true); grdEntities.Rebind(); grdEntities.Items[DestinationSortOrder].Selected = true; } }
protected void RadGridClassStudent_OnRowDrop(object sender, GridDragDropEventArgs e) { if (e.DraggedItems.Count != 0) { foreach (var dataItem in e.DraggedItems) { var sid = dataItem.GetDataKeyValue("ProgramClassStudentId").ToString(); var cProgramClassStudent = new CProgramClassStudent(); var programClassStudent = cProgramClassStudent.Get(Convert.ToInt32(sid)); var cStudent = new CStudent(); var student = cStudent.Get(programClassStudent.StudentId); var cProgramRegistration = new CProgramRegistration(); var programRegistration = cProgramRegistration.Get(programClassStudent.ProgramRegistrationId); if (programRegistration.EndDate < DateTime.Today) { ShowMessage("Move Failed : " + cStudent.GetStudentName(student) + "'s the End Date should not be earlier than today."); } else if (cProgramClassStudent.Delete(programClassStudent)) { ShowMessage("Moved successfuly : " + cStudent.GetStudentName(student)); } } refreshGrid(); } else { ShowMessage("Transfer Failed"); } }
protected void RadGridSiteLocationUser_OnRowDrop(object sender, GridDragDropEventArgs e) { //if (e.DraggedItems.Count != 0 && RadComboBoxMenu.CheckedItems.Count > 0 && e.DestinationGrid == RadGridSiteLocation) if (e.DraggedItems.Count != 0 && RadComboBoxMenu.CheckedItems.Count > 0) { bool isSuccess = true; foreach (var dataItem in e.DraggedItems) { if (RadComboBoxMenu.CheckedItems.Count == 1) { var cUserPermission = new CUserPermission(); var userPermission = cUserPermission.Get(Convert.ToInt32(dataItem.GetDataKeyValue("UserPermissionId").ToString())); if (userPermission != null) { if (cUserPermission.Delete(userPermission) == false) { isSuccess = false; } } } else { foreach (var checkedItem in RadComboBoxMenu.CheckedItems) { var cUserPermission = new CUserPermission(); // Search Type for siteLocation = 2 var userPermission = cUserPermission.Get(Id, Convert.ToInt32(checkedItem.Value), 2, Convert.ToInt32(dataItem.GetDataKeyValue("SiteLocationId").ToString())); if (userPermission != null) { if (cUserPermission.Delete(userPermission) == false) { isSuccess = false; } } } } } if (isSuccess) { ShowMessage("Move Success"); } else { ShowMessage("Move Error"); } } else { ShowMessage("Move Failed"); } }
protected void RadGrid_VariantSpliter_RowDrop(object sender, GridDragDropEventArgs e) { if (string.IsNullOrEmpty(e.HtmlElement) && e.DestDataItem.OwnerGridID == RadGrid_VariantSpliter.ClientID) { if (e.DraggedItems[0].OwnerGridID == RadGrid_VariantSpliter.ClientID) { #region items are Spliter if (e.DestDataItem != null) { ProductVariantMgr myProductVariantMgr = new ProductVariantMgr(); Variant_Spliter myVariant_Spliter = myProductVariantMgr.Get_Product_Variant_Spliter(e.DestDataItem.GetDataKeyValue("Variant_SpliterID").ToString()); List <Variant_Spliter> myVariant_Spliters = myProductVariantMgr.Get_Product_Variant_Spliters(myVariant_Spliter.Product_VariantID, "SortOrder"); Variant_Spliter draggedVariant_Spliter = Get_Variant_Spliter_in_List(myVariant_Spliters, e.DraggedItems[0].GetDataKeyValue("Variant_SpliterID").ToString()); Variant_Spliter destVariant_Spliter = Get_Variant_Spliter_in_List(myVariant_Spliters, e.DestDataItem.GetDataKeyValue("Variant_SpliterID").ToString()); int destIndex = myVariant_Spliters.IndexOf(destVariant_Spliter); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destIndex += 1; } myVariant_Spliters.Remove(draggedVariant_Spliter); myVariant_Spliters.Insert(destIndex, draggedVariant_Spliter); foreach (Variant_Spliter Variant_Spliter in myVariant_Spliters) { // Product Variant e2Data[] UpdateData = { new e2Data("Variant_SpliterID", Variant_Spliter.Variant_SpliterID), new e2Data("SortOrder", (myVariant_Spliters.IndexOf(Get_Variant_Spliter_in_List(myVariant_Spliters, Variant_Spliter.Variant_SpliterID)) + 1).ToString()) }; myProductVariantMgr.Edit_Product_Variant_Spliter(UpdateData); } } #endregion Control_Init(); } } }
private int getNewIndex(ref int destinationIndex, GridDragDropEventArgs e) { if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destinationIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destinationIndex += 1; } return(destinationIndex); }
protected void RadGridSiteLocation_OnRowDrop(object sender, GridDragDropEventArgs e) { //if (e.DraggedItems.Count != 0 && RadComboBoxMenu.CheckedItems.Count > 0 && e.DestinationGrid == RadGridSiteLocationUser) if (e.DraggedItems.Count != 0 && RadComboBoxMenu.CheckedItems.Count > 0) { bool isSuccess = true; foreach (var dataItem in e.DraggedItems) { foreach (var checkedItem in RadComboBoxMenu.CheckedItems) { var cUserPermission = new CUserPermission(); // Search Type for siteLocation = 2 var userPermission = cUserPermission.Get(Id, Convert.ToInt32(checkedItem.Value), 2, Convert.ToInt32(dataItem.GetDataKeyValue("SiteLocationId").ToString())); if (userPermission == null) { userPermission = new UserPermission() { SiteLocationId = Convert.ToInt32(dataItem.GetDataKeyValue("SiteLocationId").ToString()), CreatedDate = DateTime.Now, CreatedId = CurrentUserId, // Search Type for site location = 2 PermissionType = 2, MenuId = Convert.ToInt32(checkedItem.Value), UserId = Id }; if (cUserPermission.Add(userPermission) < 0) { isSuccess = false; } } } } if (isSuccess) { ShowMessage("Move Success"); } else { ShowMessage("Move Error"); } } else { ShowMessage("Move Failed"); } }
protected void Reordenar(object sender, GridDragDropEventArgs e) { if (e.DraggedItems.Count > 0 && e.DestDataItem != null) { Hashtable values = new Hashtable(); e.DraggedItems[0].ExtractValues(values); int idDragged = Convert.ToInt32(values["idPregunta"]); int draggedIndex = ((int)e.DraggedItems[0].GetDataKeyValue("ordenPregunta")); int destinationIndex = ((int)e.DestDataItem.GetDataKeyValue("ordenPregunta")); int indexDragged; try { con.ConnectionString = ConfigurationManager.ConnectionStrings["IconoCRM"].ToString(); string stmt; if (destinationIndex < draggedIndex) { indexDragged = draggedIndex++; stmt = "update sm_Pregunta set ordenPregunta = ordenPregunta+1 where idEncuesta = " + hdfEncuestaActual.Value + " and ordenPregunta >= " + destinationIndex + " and ordenPregunta<" + draggedIndex; } else { indexDragged = draggedIndex--; stmt = "update sm_Pregunta set ordenPregunta = ordenPregunta-1 where idEncuesta = " + hdfEncuestaActual.Value + " and ordenPregunta <= " + destinationIndex + " and ordenPregunta>" + draggedIndex; } SqlCommand cmd = new SqlCommand(stmt, con); con.Open(); cmd.ExecuteNonQuery(); stmt = "update sm_Pregunta set ordenPregunta =" + destinationIndex + " where idEncuesta =" + hdfEncuestaActual.Value + " and idPregunta = " + idDragged; cmd.CommandText = stmt; cmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { con.Close(); } //SqlDataSource1.UpdateParameters["destinationCategoryId"].DefaultValue = destinationIndex.ToString(); //SqlDataSource1.UpdateParameters["currentCategoryId"].DefaultValue = draggedIndex.ToString(); //if (e.DropPosition == GridItemDropPosition.Below) // SqlDataSource1.UpdateParameters["Position"].DefaultValue = "1"; //SqlDataSource1.Update(); preguntas.Rebind(); } }
protected void grdEntities_RowDrop(object sender, GridDragDropEventArgs e) { if (e.DestDataItem == null) return; var sortOrder = (int)e.DraggedItems[0].GetDataKeyValue("SortOrder"); var destinationSortOrder = (int) e.DestDataItem.GetDataKeyValue("SortOrder"); ContentGroup.ReorderEntities(sortOrder, destinationSortOrder); // Refresh cached contentgroup _contentGroup = null; grdEntities.Rebind(); grdEntities.Items[destinationSortOrder].Selected = true; }
/// <summary> /// Handles the RowDrop event of the rgWorkflowTemplateElement control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridDragDropEventArgs"/> instance containing the event data.</param> protected void rgWorkflowTemplateElement_RowDrop(object sender, GridDragDropEventArgs e) { if (string.IsNullOrEmpty(e.HtmlElement)) { if (e.DraggedItems[0].OwnerGridID == rgWorkflowTemplateElement.ClientID) { if (e.DestDataItem != null && e.DestDataItem.OwnerGridID == rgWorkflowTemplateElement.ClientID) { //reorder items in pending grid var element = WorkflowTemplateElementList.SingleOrDefault(a => a.ID == e.DestDataItem.GetDataKeyValue("ID").ToString().ToGuid()); int destinationIndex = WorkflowTemplateElementList.IndexOf(element); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destinationIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destinationIndex += 1; } var workflowTemplateElementListToMove = new List <WorkflowTemplateElementMap>(); foreach (GridDataItem draggedItem in e.DraggedItems) { var tmpElement = WorkflowTemplateElementList.SingleOrDefault(a => a.ID == draggedItem.GetDataKeyValue("ID").ToString().ToGuid()); if (tmpElement != null) { workflowTemplateElementListToMove.Add(tmpElement); } } foreach (var elementToMove in workflowTemplateElementListToMove) { WorkflowTemplateElementList.Remove(elementToMove); WorkflowTemplateElementList.Insert(destinationIndex, elementToMove); } rgWorkflowTemplateElement.Rebind(); int destinationItemIndex = destinationIndex - (rgWorkflowTemplateElement.PageSize * rgWorkflowTemplateElement.CurrentPageIndex); e.DestinationTableView.Items[destinationItemIndex].Selected = true; } } } UpdateOrder(); }
protected void grdMappings_OnRowDrop(object sender, GridDragDropEventArgs e) { if (!string.IsNullOrEmpty(e.HtmlElement)) { return; } if (e.DraggedItems[0].OwnerGridID != grdMappings.ClientID) { return; } var folderMappingsList = FolderMappingsList; var folderMapping = folderMappingsList.Find(f => f.FolderMappingID == (int)e.DestDataItem.GetDataKeyValue("FolderMappingID")); var destinationIndex = folderMappingsList.IndexOf(folderMapping); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destinationIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destinationIndex += 1; } var folderMappingsToMove = e.DraggedItems.Select(item => folderMappingsList.Find(f => f.FolderMappingID == (int)item.GetDataKeyValue("FolderMappingID"))) .Where(tmpFolderMapping => tmpFolderMapping != null).ToList(); foreach (var folderMappingToMove in folderMappingsToMove) { folderMappingsList.Remove(folderMappingToMove); folderMappingsList.Insert(destinationIndex, folderMappingToMove); } UpdateFolderMappings(folderMappingsList); FolderMappingsList = folderMappingsList; grdMappings.Rebind(); var destinationItemIndex = destinationIndex - (grdMappings.PageSize * grdMappings.CurrentPageIndex); e.DestinationTableView.Items[destinationItemIndex].Selected = true; }
protected void RadGrid_Options_RowDrop(object sender, GridDragDropEventArgs e) { if (e.DestDataItem != null && string.IsNullOrEmpty(e.HtmlElement) && e.DestDataItem.OwnerGridID == RadGrid_Options.ClientID) { ProductVariantMgr myProductVariantMgr = new ProductVariantMgr(); Property_Option myProperty_Option = myProductVariantMgr.Get_Product_Variant_Property_Option(e.DestDataItem.GetDataKeyValue("OptionID").ToString()); List <Property_Option> myProperty_Options = myProductVariantMgr.Get_Product_Variant_Property_Options(myProperty_Option.Variant_PropertyID, "SortOrder"); Property_Option draggedProperty_Option = Get_Property_Option_in_List(myProperty_Options, e.DraggedItems[0].GetDataKeyValue("OptionID").ToString()); Property_Option destProperty_Option = Get_Property_Option_in_List(myProperty_Options, e.DestDataItem.GetDataKeyValue("OptionID").ToString()); int destIndex = myProperty_Options.IndexOf(destProperty_Option); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destIndex += 1; } myProperty_Options.Remove(draggedProperty_Option); myProperty_Options.Insert(destIndex, draggedProperty_Option); foreach (Property_Option Property_Option in myProperty_Options) { // Product Variant e2Data[] UpdateData = { new e2Data("OptionID", Property_Option.OptionID), new e2Data("SortOrder", (myProperty_Options.IndexOf(Get_Property_Option_in_List(myProperty_Options, Property_Option.OptionID)) + 1).ToString()) }; myProductVariantMgr.Edit_Product_Variant_Property_Option(UpdateData); } RadGrid_Options.Rebind(); } }
protected void RadGrid_Options_RowDrop(object sender, GridDragDropEventArgs e) { if (e.DestDataItem != null && string.IsNullOrEmpty(e.HtmlElement) && e.DestDataItem.OwnerGridID == RadGrid_Options.ClientID) { ProductAttributeMgr myProductAttributeMgr = new ProductAttributeMgr(); List <Product_Attribute> myProduct_Attributes = myProductAttributeMgr.Get_Product_Attributes(_attribute_indexid); Product_Attribute draggedAttribute = Get_Attribute_in_List(myProduct_Attributes, e.DraggedItems[0].GetDataKeyValue("AttributeID").ToString()); Product_Attribute destAttribute = Get_Attribute_in_List(myProduct_Attributes, e.DestDataItem.GetDataKeyValue("AttributeID").ToString()); int destIndex = myProduct_Attributes.IndexOf(destAttribute); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destIndex += 1; } myProduct_Attributes.Remove(draggedAttribute); myProduct_Attributes.Insert(destIndex, draggedAttribute); foreach (Product_Attribute myAttribute in myProduct_Attributes) { // Product Variant e2Data[] UpdateData = { new e2Data("AttributeID", myAttribute.AttributeID), new e2Data("SortOrder", (myProduct_Attributes.IndexOf(Get_Attribute_in_List(myProduct_Attributes, myAttribute.AttributeID)) + 1).ToString()) }; myProductAttributeMgr.Edit_Product_Attribute(UpdateData); } RadGrid_Options.Rebind(); } }
protected void RadGrid_WebMedia_RowDrop(object sender, GridDragDropEventArgs e) { if (e.DestDataItem != null && string.IsNullOrEmpty(e.HtmlElement) && e.DestDataItem.OwnerGridID == RadGrid_WebMedia.ClientID) { ProductMgr myProductMgr = new ProductMgr(); List <WebMedia> myWebMedia = myProductMgr.Get_WebMedia(_productid); WebMedia draggedAttributeIndex = Get_WebMedia_in_List(myWebMedia, e.DraggedItems[0].GetDataKeyValue("WebMediaID").ToString()); WebMedia destAttributeIndex = Get_WebMedia_in_List(myWebMedia, e.DestDataItem.GetDataKeyValue("WebMediaID").ToString()); int destIndex = myWebMedia.IndexOf(destAttributeIndex); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destIndex += 1; } myWebMedia.Remove(draggedAttributeIndex); myWebMedia.Insert(destIndex, draggedAttributeIndex); foreach (WebMedia WebMedium in myWebMedia) { // Product Variant e2Data[] UpdateData = { new e2Data("WebMediaID", WebMedium.WebMediaID), new e2Data("SortOrder", (myWebMedia.IndexOf(Get_WebMedia_in_List(myWebMedia, WebMedium.WebMediaID)) + 1).ToString()) }; myProductMgr.Edit_WebMedia(UpdateData); } RadGrid_WebMedia.Rebind(); } }
protected void RadGridProgramStudent_OnRowDrop(object sender, GridDragDropEventArgs e) { if (e.DraggedItems.Count != 0) { foreach (var dataItem in e.DraggedItems) { //string pid = dataItem.GetDataKeyValue("ProgramRegistrationId").ToString(); //var preg = new CProgramRegistration(Convert.ToInt32(pid)); //preg.IsTransfer = true; //preg.TransferDate = DateTime.Now; //preg.TransferFromId = CurrentUserId; //if (preg.Update()) //{ var cProgramclassStudent = new CProgramClassStudent(); var programClassStudent = new ProgramClassStudent(); programClassStudent.ProgramClassId = Convert.ToInt32(ProgramClassId); if (ProgramCourseId != null) { programClassStudent.ProgramCourseId = Convert.ToInt32(ProgramCourseId); } programClassStudent.StudentId = Convert.ToInt32(dataItem.GetDataKeyValue("StudentId").ToString()); programClassStudent.ProgramRegistrationId = Convert.ToInt32(dataItem.GetDataKeyValue("ProgramRegistrationId").ToString()); programClassStudent.CreatedDate = DateTime.Now; programClassStudent.CreatedId = CurrentUserId; if (cProgramclassStudent.Add(programClassStudent) > 0) { ShowMessage("Transfer Success"); } } refreshGrid(); } else { ShowMessage("Transfer Failed"); } }
protected void RadGrid1_RowDrop(object sender, GridDragDropEventArgs e) { GridDataItem dataItem = e.DraggedItems[0]; Hashtable values = new Hashtable(); dataItem.ExtractValues(values); int id = (int)dataItem.GetDataKeyValue("AppointmentID"); string subject = (string)values["Subject"]; string targetSlotIndex = TargetSlotHiddenField.Value; if (targetSlotIndex != string.Empty) { HandleSchedulerDrop(id, subject, targetSlotIndex); TargetSlotHiddenField.Value = string.Empty; } RadScheduler1.Rebind(); RadGrid1.Rebind(); RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid1, RadScheduler1); }
private void _radGridDepositPayment_RowDrop(object sender, GridDragDropEventArgs e) { //if (e.DraggedItems.Count != 0 && RadGridDepositList.SelectedValue != null && e.DestinationGrid == RadGridUnDepositPayment) if (e.DraggedItems.Count != 0 && RadGridDepositList.SelectedValue != null) { foreach (var dataItem in e.DraggedItems) { var cPayDeposit = new CDepositPayment(); var payDeposit = cPayDeposit.Get(Convert.ToInt32(dataItem.GetDataKeyValue("DepositPaymentId").ToString())); if (cPayDeposit.Delete(payDeposit)) { } } ShowMessage("Completed deleting payment(s)."); } else { ShowMessage("Failed adding payment(s)."); } }
private void gridJQFactors_RowDrop(object sender, GridDragDropEventArgs e) { try { // make sure items are not null AND that the source table is equal to the destination table if ((e.DestDataItem != null && e.DraggedItems != null) && (string.Compare(e.DraggedItems[0].OwnerTableView.Name, e.DestDataItem.OwnerTableView.Name, true) == 0)) { switch (e.DestDataItem.OwnerTableView.Name) { case "Factors": long sourceFactorID = (long)e.DraggedItems[0].GetDataKeyValue("JQFactorID"); long destinationFactorID = (long)e.DestDataItem.GetDataKeyValue("JQFactorID"); JQFactor sourceFactor = this.Factors.Find(sourceFactorID); JQFactor destinationFactor = this.Factors.Find(destinationFactorID); if (sourceFactor != null && destinationFactor != null) { int destinationIndex = this.Factors.IndexOf(destinationFactor); destinationIndex = getNewIndex(ref destinationIndex, e); this.Factors.Remove(sourceFactor); this.Factors.Insert(destinationIndex, sourceFactor); } bindData(this.Factors); //toggleButtons(true); break; } } } catch (Exception ex) { base.HandleException(ex); } }
protected void tgrdPPTList_RowDrop(object sender, GridDragDropEventArgs e) { if (string.IsNullOrEmpty(e.HtmlElement)) { if (e.DestDataItem != null && e.DestDataItem.OwnerGridID == tgrdPPTList.ClientID) { //reorder items in grid IList<WebinarResource1> WebinarResource = getPresentationList(); IList<WebinarResource1> webinarResource = getPresentationList(); WebinarResource1 res = getPresentationList(webinarResource, (int)e.DestDataItem.GetDataKeyValue("ResourceID")); int destinationIndex = webinarResource.IndexOf(res); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destinationIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destinationIndex += 1; } List<WebinarResource1> QAToMove = new List<WebinarResource1>(); foreach (GridDataItem draggedItem in e.DraggedItems) { WebinarResource1 tmpOrder = getPresentationList(webinarResource, (int)draggedItem.GetDataKeyValue("ResourceID")); if (tmpOrder != null) QAToMove.Add(tmpOrder); } foreach (WebinarResource1 qaToMove in QAToMove) { webinarResource.Remove(qaToMove); webinarResource.Insert(destinationIndex, qaToMove); } for (int idx = 0; idx < webinarResource.Count; idx++) { //(int resID, int resOrder) objWebinarDA.UpdateWebinarResourceOrder(webinarResource[idx].ResourceID, idx + 1); } popResource(); } } }
protected void grdMappings_OnRowDrop(object sender, GridDragDropEventArgs e) { if (!string.IsNullOrEmpty(e.HtmlElement)) return; if (e.DraggedItems[0].OwnerGridID != grdMappings.ClientID) return; var folderMappingsList = FolderMappingsList; var folderMapping = folderMappingsList.Find(f => f.FolderMappingID == (int)e.DestDataItem.GetDataKeyValue("FolderMappingID")); var destinationIndex = folderMappingsList.IndexOf(folderMapping); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destinationIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destinationIndex += 1; } var folderMappingsToMove = e.DraggedItems.Select(item => folderMappingsList.Find(f => f.FolderMappingID == (int) item.GetDataKeyValue("FolderMappingID"))) .Where(tmpFolderMapping => tmpFolderMapping != null).ToList(); foreach (var folderMappingToMove in folderMappingsToMove) { folderMappingsList.Remove(folderMappingToMove); folderMappingsList.Insert(destinationIndex, folderMappingToMove); } UpdateFolderMappings(folderMappingsList); FolderMappingsList = folderMappingsList; grdMappings.Rebind(); var destinationItemIndex = destinationIndex - (grdMappings.PageSize * grdMappings.CurrentPageIndex); e.DestinationTableView.Items[destinationItemIndex].Selected = true; }
void gridJQFactorItems_RowDrop(object sender, GridDragDropEventArgs e) { try { // make sure items are not null AND that the source table is equal to the destination table if ((e.DestDataItem != null && e.DraggedItems != null) && (string.Compare(e.DraggedItems[0].OwnerTableView.Name, e.DestDataItem.OwnerTableView.Name, true) == 0)) { switch (e.DestDataItem.OwnerTableView.Name) { case "FactorItems": long sourceFactorItemID = (long)e.DraggedItems[0].GetDataKeyValue("JQFactorItemID"); long destinationFactorItemID = (long)e.DestDataItem.GetDataKeyValue("JQFactorItemID"); long factorID = (long)e.DestDataItem.GetDataKeyValue("JQFactorID"); JQFactorItemCollection workFactorItems = this.FactorItems.FindByFactor(factorID); JQFactorItem sourceFactorItem = workFactorItems.Find(sourceFactorItemID); JQFactorItem destinationFactorItem = workFactorItems.Find(destinationFactorItemID); if (sourceFactorItem != null && destinationFactorItem != null) { int destinationIndex = workFactorItems.IndexOf(destinationFactorItem); destinationIndex = getNewIndex(ref destinationIndex, e); // remove and add in new position workFactorItems.Remove(sourceFactorItem); workFactorItems.Insert(destinationIndex, sourceFactorItem); // remove entire group this.FactorItems.RemoveByFactor(factorID); // now add back into batch with corrected order this.FactorItems.AddRange(workFactorItems); } bindData(this.FactorItems); //removing toggling of save order button because it was //enabled even when the ShowEditFields was returning false or when user was not an HR user //toggleButtons(true); break; case "RatingScaleResponses": long sourceJQResponseID = (long)e.DraggedItems[0].GetDataKeyValue("JQResponseID"); long destinationJQResponseID = (long)e.DestDataItem.GetDataKeyValue("JQResponseID"); long ratingScaleID = (long)e.DestDataItem.GetDataKeyValue("JQRatingScaleID"); RatingScaleResponseCollection workResponses = this.RatingScaleResponses.FindByScale(ratingScaleID); RatingScaleResponse sourceResponse = workResponses.Find(sourceJQResponseID); RatingScaleResponse destinationResponse = workResponses.Find(destinationJQResponseID); if (sourceResponse != null && destinationResponse != null) { int destinationIndex = workResponses.IndexOf(destinationResponse); destinationIndex = getNewIndex(ref destinationIndex, e); // remove and add in new position workResponses.Remove(sourceResponse); workResponses.Insert(destinationIndex, sourceResponse); // remove entire scale this.RatingScaleResponses.RemoveByScale(ratingScaleID); // now add back into batch with corrected order this.RatingScaleResponses.AddRange(workResponses); } e.DestDataItem.OwnerTableView.Rebind(); //removing toggling of save order button because it was //enabled even when the ShowEditFields was returning false or when user was not an HR user //toggleButtons(true); break; } } } catch (Exception ex) { base.HandleException(ex); } }
protected void tgrdQAList_RowDrop(object sender, GridDragDropEventArgs e) { if (string.IsNullOrEmpty(e.HtmlElement)) { if (e.DestDataItem != null && e.DestDataItem.OwnerGridID == tgrdQAList.ClientID) { //reorder items in pending grid IList<WebinarRegFormQA> WebinarRegFormQA = getQAList(); IList<WebinarRegFormQA> webinarRegFormQA = getQAList(); //WebinarRegFormQA; WebinarRegFormQA qa = getQAList(webinarRegFormQA, (int)e.DestDataItem.GetDataKeyValue("qaID")); int destinationIndex = webinarRegFormQA.IndexOf(qa); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destinationIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destinationIndex += 1; } List<WebinarRegFormQA> QAToMove = new List<WebinarRegFormQA>(); foreach (GridDataItem draggedItem in e.DraggedItems) { WebinarRegFormQA tmpOrder = getQAList(webinarRegFormQA, (int)draggedItem.GetDataKeyValue("qaID")); if (tmpOrder != null) QAToMove.Add(tmpOrder); } foreach (WebinarRegFormQA qaToMove in QAToMove) { webinarRegFormQA.Remove(qaToMove); webinarRegFormQA.Insert(destinationIndex, qaToMove); } //WebinarRegFormQA = webinarRegFormQA; // for (int idx = 0; idx < webinarRegFormQA.Count; idx++) { objWebinarDA.UpdateRegFormQAOrder(webinarRegFormQA[idx].qaID, idx + 1); } popQAs(); //int destinationItemIndex = destinationIndex - (tgrdQAList.PageSize * tgrdQAList.CurrentPageIndex); //e.DestinationTableView.Items[destinationItemIndex].Selected = true; } } }
protected override void OnEditableGridRowsDragDrop(object sender, GridDragDropEventArgs e) { base.OnEditableGridRowsDragDrop(sender, e); if (e.DestDataItem != null) { int galleryIDDest = 0; int.TryParse(e.DestDataItem["GalleryID"].Text, out galleryIDDest); if (galleryIDDest > 0) { foreach (GridDataItem item in e.DraggedItems) { try { int galleryIDDrag = int.Parse(item["GalleryID"].Text); Gallery g = new Gallery(); g.Move(CategoryID, galleryIDDrag, galleryIDDest); galleryIDDest = galleryIDDrag; } catch { } } } } this.RebindGrid(); }
protected void RadGrid_VariantProperties_RowDrop(object sender, GridDragDropEventArgs e) { if (string.IsNullOrEmpty(e.HtmlElement) && e.DestDataItem != null) { if (e.DestDataItem.OwnerGridID == RadGrid_VariantSpliter.ClientID) { #region Dest drop is on Spliter ProductVariantMgr myProductVariantMgr = new ProductVariantMgr(); Variant_Property myVariant_Property = myProductVariantMgr.Get_Product_Variant_Property(e.DraggedItems[0].GetDataKeyValue("Variant_PropertyID").ToString()); Variant_Spliter myVariant_Spliter = myProductVariantMgr.Get_Product_Variant_Spliter(e.DestDataItem.GetDataKeyValue("Variant_SpliterID").ToString()); if (myVariant_Spliter.Variant_SpliterID != myVariant_Property.Variant_SpliterID) { List <Variant_Property> originVariant_Properties = myProductVariantMgr.Get_Product_Variant_Properties_BySpliterID(myVariant_Property.Variant_SpliterID); List <Variant_Property> destVariant_Properties = myProductVariantMgr.Get_Product_Variant_Properties_BySpliterID(myVariant_Spliter.Variant_SpliterID); Variant_Property draggedVariant_Property = Get_Variant_Property_in_List(originVariant_Properties, myVariant_Property.Variant_PropertyID); originVariant_Properties.Remove(draggedVariant_Property); destVariant_Properties.Add(draggedVariant_Property); // Update Property to new Spliter e2Data[] UpdateData_Property = { new e2Data("Variant_PropertyID", draggedVariant_Property.Variant_PropertyID), new e2Data("Variant_SpliterID", myVariant_Spliter.Variant_SpliterID) }; myProductVariantMgr.Edit_Product_Variant_Property(UpdateData_Property); // Sort Old list foreach (Variant_Property Variant_Property in originVariant_Properties) { // Variant Property e2Data[] UpdateData = { new e2Data("Variant_PropertyID", Variant_Property.Variant_PropertyID), new e2Data("SortOrder", (originVariant_Properties.IndexOf(Get_Variant_Property_in_List(originVariant_Properties, Variant_Property.Variant_PropertyID)) + 1).ToString()) }; myProductVariantMgr.Edit_Product_Variant_Property(UpdateData); } // Sort New list foreach (Variant_Property Variant_Property in destVariant_Properties) { // Variant Property e2Data[] UpdateData = { new e2Data("Variant_PropertyID", Variant_Property.Variant_PropertyID), new e2Data("SortOrder", (destVariant_Properties.IndexOf(Get_Variant_Property_in_List(destVariant_Properties, Variant_Property.Variant_PropertyID)) + 1).ToString()) }; myProductVariantMgr.Edit_Product_Variant_Property(UpdateData); } } #endregion } else { #region Dest drop is on Property ProductVariantMgr myProductVariantMgr = new ProductVariantMgr(); Variant_Property mydraggedVariant_Property = myProductVariantMgr.Get_Product_Variant_Property(e.DraggedItems[0].GetDataKeyValue("Variant_PropertyID").ToString()); Variant_Property mydestVariant_Property = myProductVariantMgr.Get_Product_Variant_Property(e.DestDataItem.GetDataKeyValue("Variant_PropertyID").ToString()); if (mydraggedVariant_Property.Variant_SpliterID == mydestVariant_Property.Variant_SpliterID) { // Under same spliter List <Variant_Property> myVariant_Properties = myProductVariantMgr.Get_Product_Variant_Properties_BySpliterID(mydestVariant_Property.Variant_SpliterID); Variant_Property draggedVariant_Property = Get_Variant_Property_in_List(myVariant_Properties, mydraggedVariant_Property.Variant_PropertyID); Variant_Property destVariant_Property = Get_Variant_Property_in_List(myVariant_Properties, mydestVariant_Property.Variant_PropertyID); int destIndex = myVariant_Properties.IndexOf(destVariant_Property); if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex) { destIndex -= 1; } if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex) { destIndex += 1; } myVariant_Properties.Remove(draggedVariant_Property); myVariant_Properties.Insert(destIndex, draggedVariant_Property); foreach (Variant_Property myVariant_Property in myVariant_Properties) { // Product Variant e2Data[] UpdateData = { new e2Data("Variant_PropertyID", myVariant_Property.Variant_PropertyID), new e2Data("SortOrder", (myVariant_Properties.IndexOf(Get_Variant_Property_in_List(myVariant_Properties, myVariant_Property.Variant_PropertyID)) + 1).ToString()) }; myProductVariantMgr.Edit_Product_Variant_Property(UpdateData); } } else { // Different spliter List <Variant_Property> originVariant_Properties = myProductVariantMgr.Get_Product_Variant_Properties_BySpliterID(mydraggedVariant_Property.Variant_SpliterID); List <Variant_Property> destVariant_Properties = myProductVariantMgr.Get_Product_Variant_Properties_BySpliterID(mydestVariant_Property.Variant_SpliterID); Variant_Property draggedVariant_Property = Get_Variant_Property_in_List(originVariant_Properties, mydraggedVariant_Property.Variant_PropertyID); Variant_Property destVariant_Property = Get_Variant_Property_in_List(destVariant_Properties, mydestVariant_Property.Variant_PropertyID); int destIndex = destVariant_Properties.IndexOf(destVariant_Property); if (e.DropPosition == GridItemDropPosition.Below) { destIndex += 1; } originVariant_Properties.Remove(draggedVariant_Property); destVariant_Properties.Insert(destIndex, draggedVariant_Property); // Update Property to new Spliter e2Data[] UpdateData_Property = { new e2Data("Variant_PropertyID", draggedVariant_Property.Variant_PropertyID), new e2Data("Variant_SpliterID", destVariant_Property.Variant_SpliterID) }; myProductVariantMgr.Edit_Product_Variant_Property(UpdateData_Property); // Sort Old list foreach (Variant_Property myVariant_Property in originVariant_Properties) { // Variant Property e2Data[] UpdateData = { new e2Data("Variant_PropertyID", myVariant_Property.Variant_PropertyID), new e2Data("SortOrder", (originVariant_Properties.IndexOf(Get_Variant_Property_in_List(originVariant_Properties, myVariant_Property.Variant_PropertyID)) + 1).ToString()) }; myProductVariantMgr.Edit_Product_Variant_Property(UpdateData); } // Sort New list foreach (Variant_Property myVariant_Property in destVariant_Properties) { // Variant Property e2Data[] UpdateData = { new e2Data("Variant_PropertyID", myVariant_Property.Variant_PropertyID), new e2Data("SortOrder", (destVariant_Properties.IndexOf(Get_Variant_Property_in_List(destVariant_Properties, myVariant_Property.Variant_PropertyID)) + 1).ToString()) }; myProductVariantMgr.Edit_Product_Variant_Property(UpdateData); } } #endregion } Control_Init(); } }
protected void OnGridInvoiceDetails_RowDrop(object sender, GridDragDropEventArgs e) { if (string.IsNullOrEmpty(e.HtmlElement)) { if (e.DraggedItems.Count >0 && e.DestDataItem != null) //[0].OwnerGridID == gridInvoiceDetails.ID && e.DestDataItem != null && e.DestDataItem.OwnerGridID == gridInvoiceDetails.ClientID) { if (!string.IsNullOrEmpty(Request.QueryString["InvoiceIdPK"])) { string[] args = Request.QueryString["InvoiceIdPK"].Split('-'); if(args.Length == 3) { List<InvoiceDetails> detailList = new InvoiceDetailsRepository().GetInvoiceDetailsOfInvoice( Convert.ToInt32(args[0]), args[1], Convert.ToInt32(args[2]), null) as List<InvoiceDetails>; if (detailList.Count > 0) { InvoiceDetails invoiceDetail = GetInvoiceDetailFromList(detailList, (string)e.DestDataItem.GetDataKeyValue("InvoiceDetailsId")); int destinationIndex = detailList.IndexOf(invoiceDetail); List<InvoiceDetails> listToMove = new List<InvoiceDetails>(); foreach (GridDataItem dragItem in e.DraggedItems) { InvoiceDetails detail = GetInvoiceDetailFromList(detailList, (string)dragItem.GetDataKeyValue("InvoiceDetailsId")); detailList.Remove(detail); detailList.Insert(destinationIndex, detail); } //save the idLignNumber into database for (int i = 0; i < detailList.Count; i++) { InvoiceDetails saveItem = detailList[i]; saveItem.IdLigneNumber = i + 1; new InvoiceDetailsRepository().UpdateInvoiceDetails(saveItem); } } gridInvoiceDetails.Rebind(); } } } } /* if (e.DestDataItem != null && e.DestDataItem.OwnerGridID == grdPendingOrders.ClientID) { //reorder items in pending grid IList<Order> pendingOrders = PendingOrders; Order order = GetOrder(pendingOrders, (int)e.DestDataItem.GetDataKeyValue("OrderId")); int destinationIndex = pendingOrders.IndexOf(order); List<Order> ordersToMove = new List<Order>(); foreach (GridDataItem draggedItem in e.DraggedItems) { Order tmpOrder = GetOrder(pendingOrders, (int)draggedItem.GetDataKeyValue("OrderId")); if (tmpOrder != null) ordersToMove.Add(tmpOrder); } foreach (Order orderToMove in ordersToMove) { pendingOrders.Remove(orderToMove); pendingOrders.Insert(destinationIndex, orderToMove); } PendingOrders = pendingOrders; grdPendingOrders.Rebind(); e.DestDataItem.Selected = true; } */ }
private void radList_RowDrop(object sender, GridDragDropEventArgs e) { if (this.RowDragDrop != null) this.RowDragDrop(sender, e); }
protected void RadGridUnDepositPayment_OnRowDrop(object sender, GridDragDropEventArgs e) { //if (e.DraggedItems.Count != 0 && RadGridDepositList.SelectedValue != null && e.DestinationGrid == _radGridDepositPayment) if (e.DraggedItems.Count != 0 && RadGridDepositList.SelectedValue != null) { foreach (var dataItem in e.DraggedItems) { var cPayDeposit = new CDepositPayment(); var payDeposit = new Erp2016.Lib.DepositPayment(); payDeposit.DepositId = Convert.ToInt32(RadGridDepositList.SelectedValue.ToString()); payDeposit.PaymentId = Convert.ToInt32(dataItem.GetDataKeyValue("PaymentId").ToString()); payDeposit.CreatedId = CurrentUserId; if (cPayDeposit.Add(payDeposit) > 0) { var cPayment = new CPayment(); var payment = cPayment.Get(Convert.ToInt32(dataItem.GetDataKeyValue("PaymentId").ToString())); var cHomestayChkInvoice = new CInvoice(); var homestayChkInvoice = cHomestayChkInvoice.Get(payment.InvoiceId); //if (!string.IsNullOrEmpty(homestayChkInvoice.HomestayRegistrationId.ToString())) //{ // var homestayId = Convert.ToInt32(homestayChkInvoice.HomestayRegistrationId); // var payOut = new CHomestayPayoutRequest(); // var payId = payOut.GetHomestayId(homestayId); // var cPout = new CHomestayPayoutRequest(); // var pout = cPout.Get(payId); // var cPmethod = new CPaymentMethod(); // var pmethod = cPmethod.Get(payId); // pout.PayoutStatus = 1; // if (cPout.Update(pout)) // { // if (true) // { // pmethod.PayoutId = payId; // pmethod.PayoutMethod1 = 0; // pmethod.SiteLocationId = CurrentSiteLocationId; // pmethod.CreatedId = CurrentUserId; // pmethod.CreatedDate = DateTime.Now; // cPmethod.Add(pmethod); // } // } //} } } ShowMessage("Completed adding payment(s)."); } else { ShowMessage("Failed adding payment(s)."); } }