protected override bool CanStepInHierarchy() { GridViewHierarchyRowInfo current = this.Traverser.Current as GridViewHierarchyRowInfo; if (current != null) { foreach (GridViewInfo view in (IEnumerable <GridViewInfo>)current.Views) { if (view.ChildRows.Count > 0) { return(true); } } return(false); } if (this.Traverser.Current != null) { return(this.Traverser.Current.HasChildRows()); } return(false); }
private void IterateChildRowsAndAddProduct(GridViewHierarchyRowInfo rowInfo, int idLoan) { GridViewInfo currentView = rowInfo.ActiveView; foreach (GridViewInfo view in rowInfo.Views) { rowInfo.ActiveView = view; foreach (GridViewRowInfo row in rowInfo.ChildRows) { PRODUCT newProduct = new PRODUCT { PRO_LOA_ID_FK = idLoan, PRO_NAME = row.Cells["Produit"].Value.ToString(), PRO_COM = row.Cells["Détail"].Value.ToString() }; VpretContext.Instance.vPretContext.PRODUCT.InsertOnSubmit(newProduct); VpretContext.Instance.vPretContext.SubmitChanges(); } } rowInfo.ActiveView = currentView; Log.UCRP.Debug("IterateChildRowsAndAddProduct(GridViewHierarchyRowInfo rowInfo, int idLoan) : STATUT : PASSED"); }
private void IterateChildRowsAndAddProduct(GridViewHierarchyRowInfo rowInfo) { GridViewInfo currentView = rowInfo.ActiveView; foreach (GridViewInfo view in rowInfo.Views) { rowInfo.ActiveView = view; foreach (GridViewRowInfo row in rowInfo.ChildRows) { IQueryable <PRODUCT> products = (from PRODUCT in VpretContext.Instance.vPretContext.PRODUCT where PRODUCT.PRO_LOA_ID_FK.Equals(row.Cells["PROLOAIDFK"].Value.ToString()) select PRODUCT); if (products != null) { foreach (PRODUCT product in products) { if (product.PRO_STATE == 1) { // not working row.Cells["Nom Produit"].Style.BackColor = Color.Green; row.Cells["N°Série Produit"].Style.BackColor = Color.Green; row.Cells["Commentaire Produit"].Style.BackColor = Color.Green; } else { row.Cells["Nom Produit"].Style.BackColor = Color.Red; row.Cells["N°Série Produit"].Style.BackColor = Color.Red; row.Cells["Commentaire Produit"].Style.BackColor = Color.Green; } } } VpretContext.Instance.vPretContext.SubmitChanges(); } } rowInfo.ActiveView = currentView; Log.UCRP.Debug("IterateChildRowsAndAddProduct(GridViewHierarchyRowInfo rowInfo, int idLoan) : STATUT : PASSED"); }
private void getDataFromGrid() { Log.UCTechReception.Debug("getDataFromGrid()"); VisualisationPret currentPret = new VisualisationPret(); currentPret.Photo = dateTimePicker1.Text; List <VisualisationProduct> plist = new List <VisualisationProduct>(); foreach (GridViewRowInfo row in radGridView1.Rows) { VisualisationProduct p = new VisualisationProduct(); foreach (GridViewCellInfo cellInfo in row.Cells) { if (cellInfo.Value == null) { cellInfo.Value = ""; } switch (cellInfo.ColumnInfo.Name) { case "Produit": p.Name = cellInfo.Value.ToString(); break; case "SN": p.Sn = cellInfo.Value.ToString(); break; case "CommentaireP": p.Com = cellInfo.Value.ToString(); break; default: break; } } // data from Child Rows GridViewHierarchyRowInfo hierarchyRow = row as GridViewHierarchyRowInfo; if (hierarchyRow != null) { GridViewInfo currentView = hierarchyRow.ActiveView; foreach (GridViewInfo view in hierarchyRow.Views) { hierarchyRow.ActiveView = view; List <VisualitationAccesories> alist = new List <VisualitationAccesories>(); foreach (GridViewRowInfo crow in view.ChildRows) { VisualitationAccesories a = new VisualitationAccesories(); foreach (GridViewCellInfo ccellInfo in crow.Cells) { if (ccellInfo.Value == null) { ccellInfo.Value = ""; } switch (ccellInfo.ColumnInfo.Name) { case "Accessoire": a.Name = ccellInfo.Value.ToString(); break; case "PN": a.Pn = ccellInfo.Value.ToString(); break; case "CommentaireA": a.Com = ccellInfo.Value.ToString(); break; default: break; } } alist.Add(a); } p.listAccessories = alist; hierarchyRow.ActiveView = currentView; } } plist.Add(p); } List <string> l_Photo = new List <string>(); foreach (RadListDataItem item in radListControl1.Items) { l_Photo.Add(item.ToString()); } currentPret.l_Photo = l_Photo; currentPret.listProducts = plist; detail.Add(currentPret); }
private void radGridViewCustmerReturn_ValueChanged(object sender, EventArgs e) { DataRowView cRow = this.radGridViewCutomerReturn.CurrentRow.DataBoundItem as DataRowView; DataRow currentRow = cRow.Row; GridViewDataRowInfo rrow = this.radGridViewCutomerReturn.CurrentRow as GridViewDataRowInfo; if (radGridViewCutomerReturn.CurrentCell != null) { if (radGridViewCutomerReturn.CurrentCell.Value.Equals(0)) { try { IQueryable <LOAN> loans = (from LOAN in VpretContext.Instance.vPretContext.LOAN where LOAN.LOA_CP.Equals(currentRow["N° CP"].ToString()) select LOAN); if (loans != null) { foreach (LOAN loan in loans) { VpretContext.Instance.vPretContext.LOAN.DeleteOnSubmit(loan); VpretContext.Instance.vPretContext.SubmitChanges(); } } } catch (Exception ex) { Log.UCRP.Error("Exception SQl radGridViewRetourClient_ValueChanged : " + ex.ToString()); } finally { Log.UCRP.Debug("radGridViewRetourClient_ValueChanged - Loans deleted"); } } else if (radGridViewCutomerReturn.CurrentCell.Value.Equals(1)) { CommentDialog dialog = new CommentDialog(); dialog.StartPosition = FormStartPosition.CenterScreen; dialog.ShowDialog(); // DateTime loaDate = Convert.ToDateTime(currentRow["Date LP"].ToString()); DateTime loaDateRetour = Convert.ToDateTime(currentRow["Date retour prévue"].ToString()); try { List <LOAN> loans = (from LOAN in VpretContext.Instance.vPretContext.LOAN where LOAN.LOA_CP == currentRow["N° CP"].ToString() select LOAN).ToList(); if (loans.Count() > 0) { foreach (LOAN loan in loans) { if (loan.LOA_STATE > 1) { loan.LOA_STATE = 1; } } VpretContext.Instance.vPretContext.SubmitChanges(); } else { string commG = " "; if (dialog.Comment != "") { commG = dialog.Comment; } LOAN newLoan = new LOAN { LOA_CLIENT = currentRow["Client"].ToString(), LOA_CP = currentRow["N° CP"].ToString(), // LOA_DATE = loaDate, LOA_DATE_RETOUR = loaDateRetour, LOA_NUM_CLIENT = Int32.Parse(currentRow["N° de Client"].ToString()), LOA_STATE = 1, // 0 en cours 1 à controler 2 terminé LOA_COMM_G = commG }; VpretContext.Instance.vPretContext.LOAN.InsertOnSubmit(newLoan); VpretContext.Instance.vPretContext.SubmitChanges(); int idLoan = newLoan.LOA_ID; GridViewDataRowInfo row = this.radGridViewCutomerReturn.CurrentRow as GridViewDataRowInfo; GridViewHierarchyRowInfo hierarchyRow = row as GridViewHierarchyRowInfo; if (hierarchyRow != null) { IterateChildRowsAndAddProduct(hierarchyRow, idLoan); } } } catch (Exception ex) { Log.UCRP.Error("radGridViewRetourClient_ValueChanged() : " + ex.ToString()); } finally { Log.UCRP.Debug("radGridViewRetourClient_ValueChanged() : STATUT : PASSED"); } } } }
public ChildViewExportingEventArgs(int activeViewIndex, GridViewHierarchyRowInfo row) { this.activeViewIndex = activeViewIndex; this.parentRow = row; }
private void FillDataLoanToControl(string query, Dictionary <string, string> param = null) { try { using (SqlConnection con = new SqlConnection(Properties.Settings.Default.vPretConnectionString)) { con.Open(); using (SqlCommand cmd = new SqlCommand(query, con)) { cmd.CommandType = CommandType.Text; if (param != null) { foreach (KeyValuePair <string, string> sqlparam in param) { cmd.Parameters.Add(new SqlParameter(sqlparam.Key, sqlparam.Value)); } } using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { using (DataSet ds = new DataSet()) { cmd.ExecuteNonQuery(); sda.Fill(ds); radGridViewControlTech.DataSource = ds.Tables[0]; GridViewCheckBoxColumn checkbox = new GridViewCheckBoxColumn(); checkbox.Name = "ValiderControle"; checkbox.FieldName = "ValiderControle"; checkbox.HeaderText = "Valider Contrôle"; checkbox.DataType = typeof(int); checkbox.EditMode = EditMode.OnValueChange; radGridViewControlTech.MasterTemplate.Columns.Add(checkbox); radGridViewControlTech.MasterTemplate.Columns["LOAID"].IsVisible = false; radGridViewControlTech.MasterTemplate.BestFitColumns(); radGridViewControlTech.AllowAddNewRow = false; radGridViewControlTech.AllowColumnResize = true; radGridViewControlTech.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; /* * Here the relation between Loan & product * */ GridViewTemplate template1 = new GridViewTemplate(); template1.AllowAddNewRow = false; template1.DataSource = ds.Tables[1]; radGridViewControlTech.MasterTemplate.Templates.Add(template1); GridViewRelation relation1 = new GridViewRelation(radGridViewControlTech.MasterTemplate); relation1.ChildTemplate = template1; relation1.RelationName = "Produit / Pret"; relation1.ParentColumnNames.Add("LOAID"); relation1.ChildColumnNames.Add("PROLOAIDFK"); radGridViewControlTech.Templates[0].Columns["PROLOAIDFK"].IsVisible = false; radGridViewControlTech.Templates[0].Columns["PROID"].IsVisible = false; radGridViewControlTech.Templates[0].AllowAutoSizeColumns = true; radGridViewControlTech.Templates[0].AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridViewControlTech.Templates[0].BestFitColumns(); radGridViewControlTech.Relations.Add(relation1); /** * Here the relation between Product & accessories **/ // Can't use radgridview.MasterTemplates.template for some reasons GridViewTemplate template2 = new GridViewTemplate(); template2.AllowAddNewRow = false; template2.DataSource = ds.Tables[2]; template1.Templates.Add(template2); GridViewRelation relation2 = new GridViewRelation(template1); relation2.ChildTemplate = template2; relation2.RelationName = "Produit / Accessoire"; relation2.ParentColumnNames.Add("PROID"); relation2.ChildColumnNames.Add("ACCPROIDFK"); template2.Columns["ACCPROIDFK"].IsVisible = false; template2.AllowAutoSizeColumns = true; template2.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; template2.BestFitColumns(); radGridViewControlTech.Relations.Add(relation2); template2.Columns["Nom Accessoire"].ReadOnly = true; template2.Columns["PN Accessoire"].ReadOnly = true; template2.Columns["Commentaire Accessoire"].ReadOnly = true; template1.Columns["Nom Produit"].ReadOnly = true; template1.Columns["N°Série Produit"].ReadOnly = true; template1.Columns["Commentaire Produit"].ReadOnly = true; template1.AllowDeleteRow = false; template2.AllowDeleteRow = false; radGridViewControlTech.MasterTemplate.AllowDeleteRow = false; foreach (GridViewColumn row in radGridViewControlTech.Columns) { if (row.FieldName.Equals("ValiderControle") == false) { row.ReadOnly = true; } } foreach (GridViewRowInfo rowInfo in radGridViewControlTech.Rows) { IQueryable <LOAN> loans = (from LOAN in VpretContext.Instance.vPretContext.LOAN where LOAN.LOA_ID.Equals(rowInfo.Cells["LOAID"].Value.ToString()) select LOAN); if (loans != null) { foreach (LOAN loan in loans) { GridViewDataRowInfo row = rowInfo as GridViewDataRowInfo; GridViewHierarchyRowInfo hierarchyRow = row as GridViewHierarchyRowInfo; if (hierarchyRow != null) { IterateChildRowsAndAddProduct(hierarchyRow); } if (loan.LOA_STATE == 1) { rowInfo.Cells["ValiderControle"].Value = CheckState.Checked; } } } } } } } } radGridViewControlTech.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridViewControlTech.Templates[0].AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.Dock = DockStyle.Fill; } catch (Exception ex) { Log.UCTechControle.Error("FillDataLoanToControl - Exception: " + ex.ToString()); } finally { Log.UCTechControle.Debug("FillDataLoanToControl : STATUT : PASSED"); } }