private void AddTableRow(Table T, DataRow myDataRow, int NumeroRiga, int[] orderedcols, string PanelId) { if (T == null) { return; } if (myDataRow == null) { return; } DataTable TT = myDataRow.Table; //Nuova Riga TableRow TR1 = new TableRow(); //TR1.Height = 24; T.Rows.Add(TR1); if ((NumeroRiga & 1) == 0) { TR1.CssClass = "odd"; } TableCell T_Chk = new TableCell(); hwCheckBox HwC = new hwCheckBox(); HwC.ID = "Chk_Selector_" + PanelId + "_" + NumeroRiga; HwC.Tag = NumeroRiga.ToString(); T_Chk.Controls.Add(HwC); TR1.Cells.Add(T_Chk); for (int i = 0; i < orderedcols.Length; i++) { DataColumn C = TT.Columns[orderedcols[i]]; //Aggiungo tutte le celle. TableCell TC1 = new TableCell(); TC1.Text = GetValoreFormattato(myDataRow, C.ColumnName, HelpForm.GetFormatForColumn(C)); System.Windows.Forms.HorizontalAlignment HA = HelpForm.GetAlignForColumn(C); if (HA == System.Windows.Forms.HorizontalAlignment.Right) { TC1.HorizontalAlign = HorizontalAlign.Right; } else { TC1.HorizontalAlign = HorizontalAlign.Left; } TR1.Cells.Add(TC1); } }
void AggiungiRighe() { int nrows = ToAdd.Rows.Count; ArrayList Selected = new ArrayList(); ArrayList ToRemoveFromToAdd = new ArrayList(); for (int index = 0; index < nrows; index++) { hwCheckBox HwC = GridToAdd.FindControl("Chk_Selector_" + GridToAdd.ID + "_" + index) as hwCheckBox; if (HwC == null) { continue; } if (HwC.Checked == true) { Selected.Add(index); } } /* * foreach (hwCheckBox hwC in GridToAdd.Controls) * { * if (hwC.Checked == true) * { * int i = Int32.Parse(hwC.Tag); * Selected.Add(i); * } * } */ foreach (int index in Selected) { DataRow Curr = ToAdd.Rows[index]; ToRemoveFromToAdd.Add(Curr); //La aggiunge ad Added AddRowToTable(Added, Curr); } //Rimuove tutte le righe da ToAdd foreach (DataRow ToRemove in ToRemoveFromToAdd) { ToRemove.Delete(); if (ToRemove.RowState != DataRowState.Detached) { ToRemove.AcceptChanges(); } } UpdateSourceTable(); }
void CheckUnceckAllCheckBoxes(Control C, bool check) { if (typeof(hwCheckBox).IsAssignableFrom(C.GetType())) { hwCheckBox CC = C as hwCheckBox; CC.Checked = check; } if (C.HasControls()) { foreach (Control child in C.Controls) { CheckUnceckAllCheckBoxes(child, check); } } }
void RimuoviRighe() { int nrows = Added.Rows.Count; ArrayList Selected = new ArrayList(); ArrayList ToRemoveFromAdded = new ArrayList(); for (int index = 0; index < nrows; index++) { hwCheckBox HwC = GridAdded.FindControl("Chk_Selector_" + GridAdded.ID + "_" + index) as hwCheckBox; if (HwC == null) { continue; } if (HwC.Checked == true) { Selected.Add(index); } } foreach (int index in Selected) { //Prende una riga selezionata //gridAdded.CurrentRowIndex = index; //DataRowView CurrDV = (DataRowView)gridToAdd.BindingContext[myDS, Added.TableName].Current; DataRow Curr = Added.Rows[index]; ToRemoveFromAdded.Add(Curr); //La aggiunge a ToAdd AddRowToTable(ToAdd, Curr); } //Rimuove tutte le righe da Added foreach (DataRow ToRemove in ToRemoveFromAdded) { ToRemove.Delete(); if (ToRemove.RowState != DataRowState.Detached) { ToRemove.AcceptChanges(); } } UpdateSourceTable(); }
private bool AddCustomControl(string tag, string tablename, string paramname, int HPosition, int VPosition, DataRow param, bool IsAlias, TableCell TCell) { if (tag == "") { return(false); } int dotpos = tag.IndexOf("."); string tipo = tag.Substring(0, dotpos); string[] token = tag.Substring(dotpos + 1).Split('|'); switch (tipo.ToLower()) { case "check": hwCheckBox ctrl = new hwCheckBox(); ctrl.Tag = tablename + "." + paramname + ":" + token[0] + ":" + token[1]; ctrl.Text = token[2]; ctrl.Width = ControlWidth - 20; TCell.Controls.Add(ctrl); TCell.Style.Add("text-align", "left"); TCell.Style.Add("vertical-align", "top"); //ctrl.Style.Add("left", HPosition.ToString()); //ctrl.Style.Add("top", VPosition + 8); //ctrl.Location = new Point(HPosition, VPosition + 8); if (OnePrintObbligatorio && paramname == "oneprint") { ctrl.Enabled = false; } break; case "radio": hwPanel grp = InserisciGroupBox(param, TCell); LiteralControl br; int i; Unit Altezza = new Unit(0); for (i = 0; i < token.Length / 2; i++) { hwRadioButton rb = new hwRadioButton(); rb.Tag = tablename + "." + paramname + ":" + token[2 * i]; rb.Text = token[2 * i + 1]; //rb.Width = ControlWidth - 20; rb.Height = LabelHeight; //TCell.Controls.Add(rb); grp.Controls.Add(rb); br = new LiteralControl("<br/>"); grp.Controls.Add(br); TCell.Controls.Add(grp); // come li piazziamo //rb.Location = new Point(12, Altezza); // Serve incrementarlo?? Altezza = new Unit(Altezza.Value + rb.Height.Value); } grp.Height = new Unit(Altezza.Value + grp.Height.Value); //Altezza + 10; //this.VPosition += (grp.Height - HelpHeight - 4); break; case "custom": string selectioncode = token[0]; //ReportVista.customselectionDataTable T = reportVista1.customselection; //DataRow selRow = T.FindByselectioncode(selectioncode); DataTable T = ExportVista.customselection; string filter = QHC.CmpEq("selectioncode", selectioncode); DataRow[] selRow = T.Select(filter); if (selRow == null || selRow.Length == 0) { return(false); } string parenttable = selRow[0]["tablename"].ToString(); string editlisttype = selRow[0]["editlisttype"].ToString(); string selectiontype = selRow[0]["selectiontype"].ToString(); string fieldname = selRow[0]["fieldname"].ToString(); filter = myDA.Compile(selRow[0]["filter"].ToString(), true); string filterapp = filter; AddCustomTableToDS(selRow[0], paramname, IsAlias); if (IsAlias) { parenttable += AliasCount; } GestioneClass GestAttributi = GestioneClass.GetGestioneClassForField(selectioncode, myDA, parenttable); if (GestAttributi != null) { selectiontype = "C"; if (GestAttributi.AllowSelection() == false) { myPrymaryTable.Columns[paramname].DefaultValue = GestAttributi.DefaultValue(); myPrymaryTable.Columns[paramname].AllowDBNull = GestAttributi.AllowNull(); return(false); } } if (filter != "") { filterapp = "." + filterapp; } // C(hoose) o M(anage)? bool IsAutoManage = (selectiontype.ToUpper() == "M"); bool IsAutoChoose = (selectiontype.ToUpper() == "C"); bool IsComboManage = (selectiontype.ToUpper() == "U"); // Si riporta la patch relativa al task 2525 if (false) //(paramname == "idupb" && Session["codiceresponsabile"] != null) { // Invece di inserire il groupbox, se sono un responsabile // Inserisco la classica dropdown e la filtro. hwDropDownList CB = new hwDropDownList(); CB.Style.Add("width", "302px"); string tablename2 = param["datasource"].ToString(); string paramname2 = param["paramname"].ToString(); if (IsAlias) { tablename2 += AliasCount; } //CB.Location = new Point(btn.Location.X + btn.Width + 1, 14); //CB.Width = ControlWidth - btn.Width - 20; CB.ID = paramname; //CB.DropDownStyle = ComboBoxStyle.DropDownList; CB.Tag = myPrymaryTable.TableName + "." + paramname2; string cmbfilter; cmbfilter = QHC.AppAnd(QHC.DoPar(QHC.AppOr(QHC.IsNull("idman"), QHC.CmpEq("idman", Session["codiceresponsabile"]))), QHC.CmpEq("active", "S")); GetData.SetStaticFilter(DS.Tables[tablename2], cmbfilter); hwLabel LB = InserisciLabel(param, TCell); CB.DataSource = DS.Tables[tablename2]; CB.DataValueField = "idupb"; CB.DataTextField = "title"; CB.AutoPostBack = true; TCell.Controls.Add(CB); return(false); } //Inserisco un groupbox hwPanel gb = InserisciGroupBox(param, selRow[0]["selectionname"].ToString(), TCell); //gb.Style.Add("background-color", "#bababa;"); //gb.Style.Add("border", "1px solid grey"); //gb.Style.Add("width", "95%"); //aggiungo un button hwButton btn = new hwButton(); btn.ID = "btn" + paramname; btn.Text = "Seleziona"; //btn.Location = new Point(12, 14); btn.Style.Add("width", "85px"); //btn.Height = TextHeight - 9; gb.Controls.Add(btn); LiteralControl nbsp = new LiteralControl(" "); gb.Controls.Add(nbsp); hwTextBox TBP = null; if (IsAutoChoose || IsAutoManage) { //e un textbox TBP = new hwTextBox(); TBP.ID = paramname; //TBP.Location = new Point(btn.Location.X + btn.Width + 1, 14); //TBP.Width = ControlWidth - btn.Width - 20; //TBP.Height = TextHeight; TBP.Tag = parenttable + "." + fieldname + "?x"; TBP.Style.Add("width", "179px"); gb.Controls.Add(TBP); } if (IsComboManage) { btn.Tag = "manage." + parenttable + "." + editlisttype + filterapp; hwDropDownList CBP = new hwDropDownList(); string tablename2 = param["datasource"].ToString(); string paramname2 = param["paramname"].ToString(); if (IsAlias) { tablename2 += AliasCount; } hwDropDownList CB = new hwDropDownList(); CB.Style.Add("width", "179px"); //CB.Location = new Point(btn.Location.X + btn.Width + 1, 14); //CB.Width = ControlWidth - btn.Width - 20; CB.ID = paramname; //CB.DropDownStyle = ComboBoxStyle.DropDownList; CB.Tag = myPrymaryTable.TableName + "." + paramname2; CB.DataSource = DS.Tables[tablename2]; CB.DataValueField = param["valuemember"].ToString(); CB.DataTextField = param["displaymember"].ToString(); CB.AutoPostBack = true; if ((paramname.IndexOf("level") >= 0) && (param["hintkind"].ToString().ToUpper() == "NOHINT")) { ComboToPreset.Add(CB); } gb.Controls.Add(CB); TCell.Controls.Add(gb); } if (GestAttributi != null) { TBP.Style.Add("text-align", "left"); TBP.Style.Add("width", "179px"); btn.Tag = GestAttributi.BtnTag(); gb.Tag = "AutoChoose." + TBP.ID + "." + editlisttype + "." + GestAttributi.GetFilterAutoChoose(); } else { if (IsAutoManage) { TBP.Style.Add("text-align", "right"); //TBP.TextAlign = HorizontalAlignment.Right; btn.Tag = "manage." + parenttable + "." + editlisttype + filterapp; gb.Tag = "AutoManage." + parenttable + "." + editlisttype + filterapp; } if (IsAutoChoose) { TBP.Style.Add("text-align", "left"); TBP.Style.Add("width", "179px"); //TBP.TextAlign = HorizontalAlignment.Left; btn.Tag = "choose." + parenttable + "." + editlisttype + filterapp; gb.Tag = "AutoChoose." + TBP.ID + "." + editlisttype + filterapp; } } break; case "costant": //controlli il cui valore è costante (es. il filtro bilancio deve essere 'E') bool visible = !(token[0].ToLower() == "hidden"); hwLabel lb = InserisciLabel(param, TCell); lb.Visible = visible; hwTextBox tb = InserisciTextBox(param, TCell); if (!visible) { tb.Style.Add("display", "none"); } tb.ReadOnly = true; if (!visible) { return(false); } break; } return(true); }