protected DataView GetVenueEvents() { HttpCookie cookie = Request.Cookies["BrowserDate"]; if (cookie == null) { cookie = new HttpCookie("BrowserDate"); cookie.Value = DateTime.Now.ToString(); cookie.Expires = DateTime.Now.AddDays(22); Response.Cookies.Add(cookie); } Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"))); string id = Request.QueryString["ID"].ToString(); DataView dvNormal = dat.GetDataDV("SELECT EO.DateTimeStart AS Start, EO.DateTimeEnd AS " + "[End], E.Header, CONVERT(NVARCHAR,E.ID)+';E;'+CONVERT(NVARCHAR,EO.ID) AS ID, V.Name "+ "FROM Event_Occurance EO, Events E, Venues " + "V WHERE EO.EventID=E.ID AND E.Venue=V.ID AND V.ID=" + id); DataView dvGroupPublic = dat.GetDataDV("SELECT EO.DateTimeStart AS Start, EO.DateTimeEnd AS " + "[End], E.Name AS Header, CONVERT(NVARCHAR,E.ID)+';G;'+CONVERT(NVARCHAR,EO.ID) AS ID, EO.ID "+ "AS ReoccurrID, V.Name FROM GroupEvent_Occurance EO, GroupEvents E, Venues " + "V WHERE E.EventType='1' AND EO.GroupEventID=E.ID AND EO.VenueID=V.ID AND V.ID=" + id); DataView dvGroupInvited = new DataView(); if (Session["User"] != null) { dvGroupInvited = dat.GetDataDV("SELECT EO.DateTimeStart AS Start, EO.DateTimeEnd AS " + "[End], E.Name AS Header, CONVERT(NVARCHAR,E.ID)+';G;'+CONVERT(NVARCHAR,EO.ID) AS ID, EO.ID " + "AS ReoccurrID, V.Name FROM GroupEvent_Occurance EO, GroupEvents E, GroupEvent_Members GEM, Venues " + "V WHERE E.EventType <> '1' AND GEM.UserID=" + Session["User"].ToString() + " AND GEM.GroupEventID=E.ID AND GEM.ReoccurrID=EO.ID " + "AND EO.GroupEventID=E.ID AND EO.VenueID=V.ID AND V.ID=" + id); } return MergeDV(MergeDV(dvGroupPublic, dvGroupInvited), dvNormal); }
public DataViewTest() { _dataTable = new DataTable("itemTable"); _dc1 = new DataColumn("itemId"); _dc2 = new DataColumn("itemName"); _dc3 = new DataColumn("itemPrice"); _dc4 = new DataColumn("itemCategory"); _dataTable.Columns.Add(_dc1); _dataTable.Columns.Add(_dc2); _dataTable.Columns.Add(_dc3); _dataTable.Columns.Add(_dc4); DataRow dr; _seed = 123; _rowCount = 5; _rndm = new Random(_seed); for (int i = 1; i <= _rowCount; i++) { dr = _dataTable.NewRow(); dr["itemId"] = "item " + i; dr["itemName"] = "name " + _rndm.Next(); dr["itemPrice"] = "Rs. " + (_rndm.Next() % 1000); dr["itemCategory"] = "Cat " + ((_rndm.Next() % 10) + 1); _dataTable.Rows.Add(dr); } _dataTable.AcceptChanges(); _dataView = new DataView(_dataTable); _dataView.ListChanged += new ListChangedEventHandler(OnListChanged); _listChangedArgs = null; }
public DataView decryptDataView(DataView dataView) { // Converting DataView into DataTable DataTable EncryptedTable = dataView.ToTable(); // getting table rows count int tableRows = EncryptedTable.Rows.Count; // getting table coulumns count int tableColumns = EncryptedTable.Columns.Count; // Creating a new Table to handle Encrypted Values DataTable UncryptedTable = new DataTable(); //copying each table row for (int i=0; tableRows < i; i++) { // copying each table column for (int j=0; tableColumns < j; i++) { UncryptedTable.Rows[i][j] = EncryptedTable.Rows[i][j]; // Unincrypting data UncryptedTable.Rows[i][j] = Crypto.Decrypt(EncryptedTable.Rows[i][j].ToString()); } } // Converting Uncrypted Table into a Dataview for Response var UncryptedDataView = new DataView(UncryptedTable); // Sending Uncrypted Data View return UncryptedDataView; }
protected void btnSortByName_Click(object sender, EventArgs e) { dv = (DataView)GridView1.DataSource; if (listTeam.SelectedItem.ToString() == "" || listPosition.SelectedItem.ToString() == "") { dv.Sort = "sukunimi ASC"; GridView1.DataSource = dv; GridView1.DataBind(); } else { if (listPosition.SelectedItem.ToString() != "") { dv.RowFilter = "seura = " + "'" + listTeam.SelectedItem.ToString() + "' AND pelipaikka = " + "'" + listPosition.SelectedItem.ToString() + "'"; } else { dv.RowFilter = "seura = " + "'" + listTeam.SelectedItem.ToString() + "'"; Label1.Text = "seura = " + "'" + listTeam.SelectedItem.ToString() + "'"; } dv.RowStateFilter = DataViewRowState.CurrentRows; dv.Sort = "sukunimi ASC"; GridView1.DataSource = dv; GridView1.DataBind(); } }
private void initDateDataView() { if (!"".Equals(ddlDate.Text)) { DataView dvStock = new DataView(); //if (ddlDate.SelectedIndex.Equals(0)) //{ // dvStock = FundDataMem.GetData(FundDataSetType.FundDataType.基金持股历史, "FUNDID:" + HidFundID.Value + ";SEASON:" + ddlDate.Text); //} //else //{ //} dvStock = FundDataMem.GetData(FundDataSetType.FundDataType.基金持股历史, HidFundID.Value.Trim(), ddlDate.Text.Trim()); //基金持股详情 if (dvStock != null && dvStock.Table.Rows.Count > 0) { GridViewStock.DataSource = dvStock; GridViewStock.DataBind(); } else { tDate.Visible = false; Label1.Visible = true; } //填写序号列 for (int i = 0; i < GridViewStock.Rows.Count; i++) GridViewStock.Rows[i].Cells[0].Text = Convert.ToString(i + 1); } }
protected void btnGetIncidents_Click(object sender, EventArgs e) { lstIncidents.Items.Clear(); myView = (DataView)dsIncidents.Select(DataSourceSelectArguments.Empty); myView.RowFilter = "CustomerID='" + txtCustomerID.Text + "' AND DateClosed IS NOT NULL"; lstIncidents.Items.Add("--Select an incident--"); lstIncidents.Items[0].Value = "None"; if (myView.Count == 0) { Deny(); lstIncidents.Items.Clear(); lstIncidents.Items.Add("There are no incidents linked to this account"); } else { custid = Convert.ToInt32(txtCustomerID.Text); int i = 1; foreach (DataRowView v in myView) { DataRowView rowResult = v; inc = new Incident(rowResult); lstIncidents.Items.Add(inc.CustomerIncidentDisplay()); lstIncidents.Items[i].Value = Convert.ToString(inc.IncidentID); i++; } lstIncidents.Focus(); Allow(); } }
protected void dpNextPrevious_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e) { int startRow = e.StartRowIndex; if (this.Run) { // Reset the start row so all rows are returned. This is needed when the user // clicks on view all records. startRow = 0; } // Re-bind dpNextPrevious1.SetPageProperties(startRow, e.MaximumRows, false); dpNextPrevious2.SetPageProperties(startRow, e.MaximumRows, false); con = new SqlConnection(ConfigurationManager.ConnectionStrings[dbConnStr].ConnectionString); con.Open(); dataView = new DataView(); dataView = reportTable.DefaultView; dataView.Sort = string.Format("{0} {1}", sortExpression, sortOrder); con.Close(); lvAccessories.DataSource = dataView; lvAccessories.DataBind(); ViewState["dataTable"] = reportTable; }
protected void Fill_User_Header() { DataView view = null; SqlConnection con; SqlCommand cmd = new SqlCommand(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/BitOp"); System.Configuration.ConnectionStringSettings connString; connString = rootWebConfig.ConnectionStrings.ConnectionStrings["BopDBConnectionString"]; con = new SqlConnection(connString.ToString()); cmd.Connection = con; con.Open(); string sql = @"SELECT Fecha_Desde, Inicio_Nombre, Region, Supervisor FROM Criterios WHERE Criterio_ID = " + @Criterio_ID; SqlDataAdapter da = new SqlDataAdapter(sql, con); da.Fill(ds); dt = ds.Tables[0]; view = new DataView(dt); foreach (DataRowView row in view) { Lbl_Fecha_Desde.Text = row["Fecha_Desde"].ToString("dd-MM-yyyy"); Lbl_Inicio_Descrip.Text = row["Inicio_Nombre"].ToString(); Lbl_Region.Text = row["Region"].ToString(); Lbl_Supervisor.Text = row["Supervisor"].ToString(); } con.Close(); }
public void SortDescriptionTest() { IBindingListView view = new DataView(_table); ListSortDescriptionCollection col = view.SortDescriptions; ((DataView)view).Sort = ""; col = view.SortDescriptions; Assert.Equal(0, col.Count); ((DataView)view).Sort = null; col = view.SortDescriptions; Assert.Equal(0, col.Count); ((DataView)view).Sort = "col1 DESC, col2 ASC"; col = view.SortDescriptions; Assert.Equal(2, col.Count); Assert.Equal("col1", col[0].PropertyDescriptor.Name); Assert.Equal(ListSortDirection.Descending, col[0].SortDirection); Assert.Equal("col2", col[1].PropertyDescriptor.Name); Assert.Equal(ListSortDirection.Ascending, col[1].SortDirection); //ApplySort Test IBindingListView view1 = new DataView(_table); Assert.False(view.Equals(view1)); view1.ApplySort(col); Assert.Equal("[col1] DESC,[col2]", ((DataView)view1).Sort); for (int i = 0; i < view.Count; ++i) Assert.Equal(((DataView)view)[i].Row, ((DataView)view1)[i].Row); }
public void CancelEdit() { DataTable dt = DataProvider.CreateParentDataTable(); DataView dv = new DataView(dt); DataRowView drv = dv[0]; drv.BeginEdit(); drv["String1"] = "ChangeValue"; // check Proposed value Assert.Equal("ChangeValue", dt.Rows[0]["String1", DataRowVersion.Proposed]); // check IsEdit Assert.Equal(true, drv.IsEdit); // check Proposed value drv.CancelEdit(); Assert.Equal(false, dt.Rows[0].HasVersion(DataRowVersion.Proposed)); // check current value Assert.Equal("1-String1", dt.Rows[0]["String1", DataRowVersion.Current]); // check IsEdit after cancel edit Assert.Equal(false, drv.IsEdit); }
private ICollection CreateDataSource(IList<IBShopScript> scriptList) { if (scriptList != null && scriptList.Count != 0) { try { DataTable dataTable = new DataTable(); DataRow dataRow; dataTable.Columns.Add(new DataColumn("ID", typeof(Int32))); dataTable.Columns.Add(new DataColumn("TimeStamp", typeof(String))); foreach (IBShopScript script in scriptList) { dataRow = dataTable.NewRow(); dataRow[0] = script.ID; dataRow[1] = script.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss"); dataTable.Rows.Add(dataRow); } DataView dataView = new DataView(dataTable); dataView.Sort = "ID ASC"; return dataView; } catch (Exception) { return null; } } return null; }
protected void btnAddUser_Click(object sender, EventArgs e) { DealerUsers objUsers = new DealerUsers(); DataTable dtUsers = new DataTable(); dtUsers = (DataTable)Session["DealerUsers"]; DataView dv = new DataView(); DataTable dt = new DataTable(); dv = dtUsers.DefaultView; dv.RowFilter = "UserID='" + txtUserID.Text + "'"; dt = dv.ToTable(); if (dt.Rows.Count == 0) { objUsers.AddDealerUsers(Session[Constants.DealerCode].ToString(), "0", txtName.Text, txtUserID.Text, txtPassword.Text, txtUserName.Text, txtPhoneNumber.Text, Convert.ToInt32(ddlActive.SelectedItem.Value)); FillUsers(); } else { MpeAlert.Show(); lblErrorMSg.Visible = true; lblErrorMSg.Text = "User ID already exists."; } }
protected void Button1_Click(object sender, EventArgs e) { string[] strArray = new string[5] { "Delhi", "Mumbai", "Kolkata", "Chennai", "Chandigarh" }; foreach (string str in strArray) { OdbcConnection oledbConn = new OdbcConnection("DSN=exceldb"); try { // Open connection oledbConn.Open(); // Create OleDbCommand object and select data from worksheet Sheet1 OdbcCommand cmd = new OdbcCommand("SELECT * FROM [Details$]", oledbConn); //cmd.Parameters.AddWithValue("@city",str);where city=@city // Create new OleDbDataAdapter OdbcDataAdapter oleda = new OdbcDataAdapter(); oleda.SelectCommand = cmd; // Create a DataSet which will hold the data extracted from the worksheet. // DataSet ds = new DataSet(); DataTable dt = new DataTable(); // Fill the DataSet from the data extracted from the worksheet. oleda.Fill(dt); /* if(dt.Rows.Count>0) { ID = dt.Rows[0]["ID"].ToString(); //Where ColumnName is the Field from the DB that you want to display name= dt.Rows[0]["Name"].ToString(); Address = dt.Rows[0]["Address"].ToString(); EmailAddress = dt.Rows[0]["emailaddress"].ToString(); if(EmailAddress!=null) { if(EmailAddress==) } EmailContent = dt.Rows[0]["emailcontent"].ToString(); } */ DataView dv = new DataView(dt); // dv.Sort = "emailcontents"; // dv.Sort = "Name"; // Bind the data to the GridView Grdexcel.DataSource = dv; Grdexcel.DataBind(); // cmd = new OdbcCommand("delete FROM [ter$] where Address like 'M%'", oledbConn); // cmd.ExecuteNonQuery(); //cmd.CommandType } catch (Exception ex) { Alert.Show("Sorry"); } finally { // Close connection oledbConn.Close(); } } }
protected void Page_Load(object sender, EventArgs e) { user = User.Identity.Name; DataTable MyQuestionsTable = new QuesDB().GetMyQuestions(user); if (MyQuestionsTable.Rows.Count != 0) { DataView MyQuestions = new DataView(); MyQuestions.Table = MyQuestionsTable; MyQuestionsView.SetActiveView(QuestionsPresent); if (SelectionCriteria.SelectedItem.Value == "All") MyQuestions.Sort = "PostedTime DESC"; else if (SelectionCriteria.SelectedItem.Value == "Answered") { MyQuestions.RowFilter = "Answered = 1"; MyQuestions.Sort = "PostedTime DESC"; } else if (SelectionCriteria.SelectedItem.Value == "Unanswered") { MyQuestions.RowFilter = "Answered = 0"; MyQuestions.Sort = "PostedTime DESC"; } questionsList.DataSource = MyQuestions; } else MyQuestionsView.SetActiveView(NoQuestions); }
protected void FillGrid() { if (!IsValidFormID()) { HideTableAndSetErrorMessage("", "Invalid URL Parameters"); return; } Organisation org = OrganisationDB.GetByID(GetFormID()); if (org == null) { HideTableAndSetErrorMessage("", "Invalid URL Parameters"); return; } lblHeading.Text = Page.Title = "Manage Registrations For : " + org.Name; this.lnkThisOrg.NavigateUrl = "~/OrganisationDetailV2.aspx?type=view&id=" + GetFormID().ToString(); this.lnkThisOrg.Text = "Back to details for " + org.Name; DataTable dt = RegisterReferrerDB.GetDataTable_ReferrersOf(org.OrganisationID); Session["registerreferrertoorg_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["registerreferrertoorg_sortexpression"] != null && Session["registerreferrertoorg_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["registerreferrertoorg_sortexpression"].ToString(); GrdRegistration.DataSource = dataView; } else { GrdRegistration.DataSource = dt; } try { GrdRegistration.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdRegistration.DataSource = dt; GrdRegistration.DataBind(); int TotalColumns = GrdRegistration.Rows[0].Cells.Count; GrdRegistration.Rows[0].Cells.Clear(); GrdRegistration.Rows[0].Cells.Add(new TableCell()); GrdRegistration.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdRegistration.Rows[0].Cells[0].Text = "No Record Found"; } if (hideFotter) GrdRegistration.FooterRow.Visible = false; }
protected void Page_Load(object sender, EventArgs e) { TopRecipeID = new RecipeDB().getTopRecipe(); if (TopRecipeID != 0) { TopRecipeDiv.Visible = true; RecipeClass TopRecipeClass = new RecipeDB().GetRecipe(TopRecipeID); TopRecipeName = TopRecipeClass.RecipeName; TopRecipeImage = TopRecipeClass.ImagePath; } else TopRecipeDiv.Visible = false; DataTable AllRecipesTable = (new RecipeDB()).GetLatestRecipes(); if (AllRecipesTable.Rows.Count > 0) { DataView ListView = new DataView(); ListView.Table = AllRecipesTable; AllRecipeList.DataSource = ListView; } DataTable LatestArticles = new ArticleDB().GetLatestArticles(); ArticlesRepeater.DataSource = LatestArticles; this.DataBind(); }
public void PopulateDatagrid() { try { string connectionString = ConfigurationManager.ConnectionStrings["JewleryStore"].ConnectionString; string sqlQuery = "SELECT Types, Price " + " FROM Product; "; SqlDataAdapter outlookRecords = new SqlDataAdapter(sqlQuery, connectionString); // Create and fill a DataSet. DataSet ds = new DataSet(); outlookRecords.Fill(ds); DataView dv = new DataView(ds.Tables[0]); ProductsGrid.DataSource = dv; ProductsGrid.DataBind(); } catch (Exception exc) { statusL.Text = exc.Message; } }
protected void Page_Load(object sender, EventArgs e) { DataTable articlesTable = new ArticleDB().GetAllVerifiedArticles(); if (articlesTable.Rows.Count > 0) { DataView articlesView = new DataView(); articlesView.Table = articlesTable; if (Sort.SelectedItem.Value == "Latest") articlesView.Sort = "PostedTime DESC"; else if (Sort.SelectedItem.Value == "Popular") articlesView.Sort = "ArticleViews DESC"; if (articlesView.Count == 0) PagerDiv.Visible = false; else PagerDiv.Visible = true; articlesList.DataSource = articlesView; NoArticleLbl.Visible = false; ArticlesDiv.Visible = true; } else { ArticlesDiv.Visible = false; NoArticleLbl.Visible = true; } }
public void DataBind2(DataView dvAds) { try { HttpCookie cookie = Request.Cookies["BrowserDate"]; Data dat = new Data(DateTime.Parse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"))); if(Session["AD4Count"] == null) Session["AD4Count"] = 0; Session["AD4DV"] = dvAds; DrawAd((int)Session["AD4Count"], dvAds); } catch (Exception ex) { BodyLabel.Text = ex.ToString(); } //AD1 CODE DOES THIS FOR US //if (Session["User"] != null) //{ // dat.CountAd(false); //} //Ajax.Utility.RegisterTypeForAjax(typeof(Ad4)); //XmlDataSource xmlAds = new XmlDataSource(); //xmlAds.DataFile = Server.MapPath(".") + "\\UserFiles\\categoies4.xml"; //xmlAds.DataBind(); //RadRotator1.DataSource = xmlAds; //RadRotator1.DataBind(); }
public void AddNewTest() { DataView dv = new DataView(_dt); IBindingList ib = dv; ib.ListChanged += new ListChangedEventHandler(OnListChanged); try { _args = null; object o = ib.AddNew(); Assert.Equal(typeof(DataRowView), o.GetType()); Assert.Equal(ListChangedType.ItemAdded, _args.ListChangedType); Assert.Equal(4, _args.NewIndex); Assert.Equal(-1, _args.OldIndex); DataRowView r = (DataRowView)o; Assert.Equal(25, r["id"]); Assert.Equal(DBNull.Value, r["name"]); Assert.Equal(5, dv.Count); _args = null; r.CancelEdit(); Assert.Equal(ListChangedType.ItemDeleted, _args.ListChangedType); Assert.Equal(4, _args.NewIndex); Assert.Equal(-1, _args.OldIndex); Assert.Equal(4, dv.Count); } finally { ib.ListChanged -= new ListChangedEventHandler(OnListChanged); } }
/// <summary> /// Get Order details click event /// </summary> protected void btnOrderFilter_Click(object sender, EventArgs e) { objReportViewer.Visible = true; Mode = "271"; //Get Filetered Orders in DataSet OrderAdmin _OrderAdmin = new OrderAdmin(); dsOrders = _OrderAdmin.ReportList(Mode, Year, ddlSupplier.SelectedValue); dsOrdersLineItems = _OrderAdmin.GetAllOrderLineItems().ToDataSet(false); DataView dv = new DataView(dsOrders.Tables[0]); DataView dv1 = new DataView(); dsOrders = _OrderAdmin.ReportList(Mode, Year,ddlSupplier.SelectedValue); dv = new DataView(dsOrders.Tables[0]); DateTime StartDate = DateTime.Parse(txtStartDate.Text.Trim()); DateTime EndDate = DateTime.Parse(txtEndDate.Text.Trim()); dv.RowFilter = "orderdate >= '" + StartDate + "' and orderdate <= '" + EndDate.AddDays(1) + "'"; if (dv.ToTable().Rows.Count == 0) { lblErrorMsg.Text = "No records found"; objReportViewer.Visible = false; return; } objReportViewer.LocalReport.DataSources.Clear(); ReportParameter param1 = new ReportParameter("CurrentLanguage", System.Globalization.CultureInfo.CurrentCulture.Name); objReportViewer.LocalReport.SetParameters(new ReportParameter[] { param1 }); this.objReportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing); objReportViewer.LocalReport.DataSources.Add(new ReportDataSource("ZNodeOrderDataSet_ZNodeOrder", dv)); objReportViewer.LocalReport.Refresh(); }
public void GetModelsInfo() { try { //var objModel = new List<MakesInfo>(); //objModel = Session["AllModel"] as List<MakesInfo>; DataSet dsModels = Session[Constants.AllModel] as DataSet; int makeid = Convert.ToInt32(ddlMake.SelectedItem.Value); DataView dvModel = new DataView(); DataTable dtModel = new DataTable(); dvModel = dsModels.Tables[0].DefaultView; dvModel.RowFilter = "MakeID='" + makeid.ToString() + "'"; dtModel = dvModel.ToTable(); ddlModel.DataSource = dtModel; ddlModel.Items.Clear(); ddlModel.DataTextField = "Model"; ddlModel.DataValueField = "MakeModelID"; ddlModel.DataBind(); ddlModel.Items.Insert(0, new ListItem("Unspecified", "0")); } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, System.EventArgs e) { // Create the Connection, DataAdapter, and DataSet. string connectionString = "Data Source=localhost;Initial Catalog=Northwind;" + "Integrated Security=SSPI"; SqlConnection con = new SqlConnection(connectionString); string sql = "SELECT TOP 5 EmployeeID, TitleOfCourtesy, LastName, FirstName FROM Employees"; SqlDataAdapter da = new SqlDataAdapter(sql, con); DataSet ds = new DataSet(); // Fill the DataSet da.Fill(ds, "Employees"); // Bind the original data to #1. Datagrid1.DataSource = ds.Tables["Employees"]; // Sort by last name and bind it to #2. DataView view2 = new DataView(ds.Tables["Employees"]); view2.Sort = "LastName"; Datagrid2.DataSource = view2; // Sort by first name and bind it to #3. DataView view3 = new DataView(ds.Tables["Employees"]); view3.Sort = "FirstName"; Datagrid3.DataSource = view3; // Bind all the data-bound controls on the page. // Alternatively, you could call the DataBind() method // of each grid separately this.DataBind(); }
public static string constr = "DSN=ground_tariff"; //@"Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=d:\documents and settings\axkhan2\desktop\437proj\GHEC Rates NL.xls;DefaultDir=d:\documents and settings\axkhan2\desktop\437proj\;"; static void Main() { OdbcConnection conxls = new OdbcConnection(constr); try { conxls.Open(); OdbcDataAdapter da = new OdbcDataAdapter("select * from [Sheet1$]", conxls); DataSet set = new DataSet(); da.Fill(set, "mytariff"); DataTable table = set.Tables[0]; DataView dv = new DataView(table); // Console.WriteLine(dv[0]); //InsertData(rdxls); } catch(OdbcException od) { Console.WriteLine(od.Message); } finally { conxls.Close(); } }
public static string[] GetClassValue(int classId) { EasyDataProvide ModuleClass = new EasyDataProvide("ModuleClass"); DataTable dtClass = ModuleClass.GetAllData(); string[] classValues = new string[3]; DataView dv3 = new DataView(dtClass); dv3.RowFilter = "id=" + classId; if (dv3.Count > 0) { classValues[2] = dv3[0]["id"].ToString(); DataView dv2 = new DataView(dtClass); dv2.RowFilter = "id=" + dv3[0]["parentID"].ToString(); if (dv2.Count > 0) { classValues[1] = dv2[0]["id"].ToString(); DataView dv1 = new DataView(dtClass); dv1.RowFilter = "id=" + dv2[0]["parentID"].ToString(); if (dv1.Count > 0) { classValues[0] = dv1[0]["id"].ToString(); } } } return classValues; }
public void AddNew() { //create the source datatable DataTable dt = DataProvider.CreateChildDataTable(); //create the dataview for the table DataView dv = new DataView(dt); int CountView = dv.Count; int CountTable = dt.Rows.Count; DataRowView drv = null; // AddNew - DataView Row Count drv = dv.AddNew(); Assert.Equal(dv.Count, CountView + 1); // AddNew - Table Row Count Assert.Equal(dt.Rows.Count, CountTable); // AddNew - new row in DataTable drv.EndEdit(); Assert.Equal(dt.Rows.Count, CountTable + 1); // AddNew - new row != null Assert.Equal(true, drv != null); // AddNew - check table Assert.Equal(dt, drv.Row.Table); }
protected void Page_Load(object sender, EventArgs e) { DataTable myTable = new DataTable("myTable"); DataColumn colItem = new DataColumn("item", Type.GetType("System.String")); DataColumn colItem1 = new DataColumn("item1", Type.GetType("System.Int32")); myTable.Columns.Add(colItem); myTable.Columns.Add(colItem1); // Add five items. DataRow NewRow; for (int i = 0; i < 2; i++) { NewRow = myTable.NewRow(); NewRow["item"] = i; myTable.Rows.Add(NewRow); } myTable.Rows[0]["item"] = "Juan"; myTable.Rows[0]["item1"] = "60"; myTable.Rows[1]["item"] = "Diego"; myTable.Rows[1]["item1"] = "40"; myTable.AcceptChanges(); //DataView custDV = new DataView(custDS.Tables["Customers"], "Country = 'USA'", "ContactName", DataViewRowState.CurrentRows); DataView custDV = new DataView(myTable); //Display(custDV); }
protected void Page_Load(object sender, System.EventArgs e) { // Create the Connection, DataAdapter, and DataSet. string connectionString = "Data Source=localhost;Initial Catalog=Northwind;" + "Integrated Security=SSPI"; SqlConnection con = new SqlConnection(connectionString); string sql = "SELECT ProductID, ProductName, UnitsInStock, UnitsOnOrder, Discontinued FROM Products"; SqlDataAdapter da = new SqlDataAdapter(sql, con); DataSet ds = new DataSet(); // Fill the DataSet da.Fill(ds, "Products"); // Filter for the Chocolade product. DataView view1 = new DataView(ds.Tables["Products"]); view1.RowFilter = "ProductName = 'Chocolade'"; Datagrid1.DataSource = view1; // Filter for products that aren't on order or in stock. DataView view2 = new DataView(ds.Tables["Products"]); view2.RowFilter = "UnitsInStock = 0 AND UnitsOnOrder = 0"; Datagrid2.DataSource = view2; // Filter for products starting with the letter P. DataView view3 = new DataView(ds.Tables["Products"]); view3.RowFilter = "ProductName LIKE 'P%'"; Datagrid3.DataSource = view3; // Bind all the data-bound controls on the page. // Alternatively, you could call the DataBind() method // of each grid separately this.DataBind(); }
private void BindData(bool IsReload) { DataTable dt = dt = new DAL.Views.V_UserDistills().Open("", "IsCps=1 and Result=10 and SiteID = " + _Site.ID.ToString(), "[DateTime] desc"); if (dt == null) { PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", "Admin_FinanceDistill"); return; } string filterCondition = GetFilterCondition(); DataView dv = new DataView(dt, filterCondition, "[DateTime] desc", DataViewRowState.OriginalRows); PF.DataGridBindData(g, dv, gPager); //根据条件显示或隐藏列 for (int i = 0; i < g.Columns.Count; i++) { if (g.Columns[i].HeaderText == "提款银行卡帐号" || g.Columns[i].HeaderText == "开户银行" || g.Columns[i].HeaderText == "支行名称" || g.Columns[i].HeaderText == "所在省" || g.Columns[i].HeaderText == "所在市" || g.Columns[i].HeaderText == "持卡人姓名") { g.Columns[i].Visible = (hfCurPayType.Value == "所有" || hfCurPayType.Value == "银行卡") ? true : false; } else if (g.Columns[i].HeaderText == "支付宝账号") { g.Columns[i].Visible = true; g.Columns[i].Visible = (hfCurPayType.Value == "所有" || hfCurPayType.Value == "支付宝") ? true : false; } } }
public void AllowDelete() { DataTable dt = DataProvider.CreateParentDataTable(); DataView dv = new DataView(dt); // AllowDelete - default value Assert.Equal(true, dv.AllowDelete); // AllowDelete - true dv.AllowDelete = true; Assert.Equal(true, dv.AllowDelete); // AllowDelete - false dv.AllowDelete = false; Assert.Equal(false, dv.AllowDelete); dv.AllowDelete = false; // AllowDelete false- Exception Assert.Throws<DataException>(() => { dv.Delete(0); }); dv.AllowDelete = true; int RowsCount = dv.Count; // AllowDelete true- Exception dv.Delete(0); Assert.Equal(RowsCount - 1, dv.Count); }
private void lwDatabaseObjects_Click(object sender, EventArgs e) { //MessageBox.Show(lwDatabaseObjects.SelectedItems[0].SubItems[0].Text + "." + lwDatabaseObjects.SelectedItems[0].SubItems[2].Text); try { lvDestination.Items.Clear(); lvSource.Items.Clear(); DataView dwObjectDefinition = new DataView(this.dbOjects, "Type='" + lwDatabaseObjects.SelectedItems[0].SubItems[0].Text + "' AND " + "Name='" + lwDatabaseObjects.SelectedItems[0].SubItems[2].Text + "'", "Name", DataViewRowState.CurrentRows); foreach (DataRowView dr in dwObjectDefinition) { //ObjectDefinition1 string objDef1 = dr["ObjectDefinition1"].ToString(); string objDef2 = dr["ObjectDefinition2"].ToString(); DiffList_TextFile sLF = null; DiffList_TextFile dLF = null; sLF = new DiffList_TextFile(objDef1); dLF = new DiffList_TextFile(objDef2); double time = 0; DiffEngine de = new DiffEngine(); time = de.ProcessDiff(sLF, dLF, DiffEngineLevel.SlowPerfect); ArrayList rep = de.DiffReport(); ListViewItem lviS; ListViewItem lviD; int cnt = 1; int i; foreach (DiffResultSpan drs in rep) { switch (drs.Status) { case DiffResultSpanStatus.DeleteSource: for (i = 0; i < drs.Length; i++) { lviS = new ListViewItem(cnt.ToString("00000")); lviD = new ListViewItem(cnt.ToString("00000")); lviS.BackColor = Color.Red; lviS.SubItems.Add(((TextLine)sLF.GetByIndex(drs.SourceIndex + i)).Line); lviD.BackColor = Color.LightGray; lviD.SubItems.Add(""); lvSource.Items.Add(lviS); lvDestination.Items.Add(lviD); cnt++; } break; case DiffResultSpanStatus.NoChange: for (i = 0; i < drs.Length; i++) { lviS = new ListViewItem(cnt.ToString("00000")); lviD = new ListViewItem(cnt.ToString("00000")); lviS.BackColor = Color.White; lviS.SubItems.Add(((TextLine)sLF.GetByIndex(drs.SourceIndex + i)).Line); lviD.BackColor = Color.White; lviD.SubItems.Add(((TextLine)dLF.GetByIndex(drs.DestIndex + i)).Line); lvSource.Items.Add(lviS); lvDestination.Items.Add(lviD); cnt++; } break; case DiffResultSpanStatus.AddDestination: for (i = 0; i < drs.Length; i++) { lviS = new ListViewItem(cnt.ToString("00000")); lviD = new ListViewItem(cnt.ToString("00000")); lviS.BackColor = Color.LightGray; lviS.SubItems.Add(""); lviD.BackColor = Color.LightGreen; lviD.SubItems.Add(((TextLine)dLF.GetByIndex(drs.DestIndex + i)).Line); lvSource.Items.Add(lviS); lvDestination.Items.Add(lviD); cnt++; } break; case DiffResultSpanStatus.Replace: for (i = 0; i < drs.Length; i++) { lviS = new ListViewItem(cnt.ToString("00000")); lviD = new ListViewItem(cnt.ToString("00000")); lviS.BackColor = Color.Red; lviS.SubItems.Add(((TextLine)sLF.GetByIndex(drs.SourceIndex + i)).Line); lviD.BackColor = Color.LightGreen; lviD.SubItems.Add(((TextLine)dLF.GetByIndex(drs.DestIndex + i)).Line); lvSource.Items.Add(lviS); lvDestination.Items.Add(lviD); cnt++; } break; } } /* * lvSource.Items.Clear(); * using (StringReader sr = new StringReader(objDef1)) * { * string line; * while ((line = sr.ReadLine()) != null) * { * lvSource.Items.Add(line); * } * } * lvDestination.Items.Clear(); * using (StringReader sr = new StringReader(objDef2)) * { * string line; * while ((line = sr.ReadLine()) != null) * { * this.lvDestination.Items.Add(line); * } * }*/ } } catch (Exception err) { string error = err.Message; } }
protected void NextPage_Click(object sender, EventArgs e) { view = loadData(info, sdb, Repeater); }
private void Page_Load(object sender, System.EventArgs e) { gID = Sql.ToGuid(Request["ID"]); Guid gCONTACT_ID = Sql.ToGuid(txtCONTACT_ID.Value); if (!Sql.IsEmptyGuid(gCONTACT_ID)) { try { SqlProcs.spCALLS_CONTACTS_Update(gID, gCONTACT_ID, false, String.Empty); Response.Redirect("view.aspx?ID=" + gID.ToString()); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwCALLS_CONTACTS " + ControlChars.CrLf + " where CALL_ID = @CALL_ID " + ControlChars.CrLf + " order by DATE_ENTERED asc" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@CALL_ID", gID); #if DEBUG Page.RegisterClientScriptBlock("vwCALLS_CONTACTS", Sql.ClientScriptBlock(cmd)); #endif try { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain; // 09/05/2005 Paul. LinkButton controls will not fire an event unless the the grid is bound. //if ( !IsPostBack ) { grdMain.DataBind(); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
public StringCollection GetInputStatistics(string inputRegionId, string sourceId, int dataWayId) { //取出该录入区域和来源的所有统计项 HybridDictionary myHd4 = new HybridDictionary(); myHd4.Add("INPUT_REGION_ID", inputRegionId); myHd4.Add("SOURCE_ID", sourceId); myHd4.Add("DATA_WAY_ID", dataWayId); DataTable tableInputStaitem = statisticItemTable.ExecuteDataTable2(CommandType.Text, "SelectUseStaitemByReginputSource", myHd4); StringCollection colInputSaitem = new StringCollection(); foreach (DataRow dr in tableInputStaitem.Rows) { colInputSaitem.Add(dr["STATISTIC_ITEM_ID"].ToString()); } //取出该来源的所有统计 HybridDictionary myHd = new HybridDictionary(); myHd.Add("SOURCE_ID", sourceId); DataTable tableStatistic = statisticTable.ExecuteDataTable2(CommandType.Text, "SelectIdNameBySourceId", myHd); DataView dvStatistic = new DataView(tableStatistic, "use_identifier <> 0", null, DataViewRowState.CurrentRows); SortedList listStatistic = new SortedList(); //获取每个统计对应的统计项 foreach (DataRowView drv in dvStatistic) { HybridDictionary hdStaitem = new HybridDictionary(); listStatistic.Add(drv["STATISTIC_ID"], null); HybridDictionary myHd2 = new HybridDictionary(); myHd2.Add("STATISTIC_ID", drv["STATISTIC_ID"]); DataTable tableTopStaitem = statisticStaitemCombTable.ExecuteDataTable2(CommandType.Text, "SelectbyID", myHd2); DataView dvTopStaitem = new DataView(tableTopStaitem, "use_identifier <> 0", null, DataViewRowState.CurrentRows); foreach (DataRowView drvTop in dvTopStaitem) { hdStaitem.Add(drvTop["STATISTIC_ITEM_ID"], drvTop["STATISTIC_ITEM_ID"]); HybridDictionary myHd3 = new HybridDictionary(); myHd3.Add("PARENT_STAITEM_ID", drvTop["STATISTIC_ITEM_ID"]); DataTable tableStaitem = staitemCombUseView.ExecuteDataTable(CommandType.Text, "SelectByTopId", myHd3); DataView dvStaitem = new DataView(tableStaitem, null, null, DataViewRowState.CurrentRows); foreach (DataRowView drvStaitem in dvStaitem) { if (!(hdStaitem.Contains(drvStaitem["CHILD_STAITEM_ID"]))) { hdStaitem.Add(drvStaitem["CHILD_STAITEM_ID"], drvStaitem["CHILD_STAITEM_ID"]); } } } listStatistic[drv["STATISTIC_ID"]] = hdStaitem; } //检查需要录入的统计项是否在各统计中是否存在 StringCollection colInputStatistic = new StringCollection(); for (int i = 0; i < listStatistic.Count; i++) { bool isExist = false; string key = listStatistic.GetKey(i).ToString(); foreach (string staitemId in colInputSaitem) { if (((HybridDictionary)(listStatistic.GetByIndex(i))).Contains(staitemId)) { isExist = true; break; } } if (isExist) { colInputStatistic.Add(key); } } return(colInputStatistic); }
protected void GV_news_RowEditing(object sender, GridViewEditEventArgs e) { DataView dv = (DataView)Session["dv_news"]; Response.Redirect("article.aspx?id=" + dv.Table.Rows[e.NewEditIndex]["id"].ToString()); }
private DataTable BindDataGrid(DataGrid dg) { _hash.Clear(); #region Filter Params int projId = ProjectID; //Project if (ProjectID == 0) { projId = int.Parse(ddlProject.SelectedValue); } //Manager int manId = 0; if (Request.QueryString["ManDoc"] != null) { manId = Security.CurrentUser.UserID; } manId = int.Parse(ddManager.SelectedValue); //Resource int resId = 0; if (Request.QueryString["AssDoc"] != null) { resId = Security.CurrentUser.UserID; } //Keyword string keyword = tbKeyword.Text; // Priority int priority_id = 0; if (Request.QueryString["DocPrty"] != null) { priority_id = int.Parse(Request.QueryString["DocPrty"]); } else if (ddPriority.SelectedItem != null) { priority_id = int.Parse(ddPriority.SelectedValue); } // Status int status_id = 0; if (Request.QueryString["DocStatus"] != null) { status_id = int.Parse(Request.QueryString["DocStatus"]); } else if (ddStatus.SelectedItem != null) { status_id = int.Parse(ddStatus.SelectedValue); } // General Category Type int genCategory_type = 0; if (Request.QueryString["GenCat"] != null) { genCategory_type = -int.Parse(Request.QueryString["GenCat"]); } else if (ddGenCatType.SelectedItem != null) { genCategory_type = int.Parse(ddGenCatType.SelectedValue); } // Client PrimaryKeyId orgUid = PrimaryKeyId.Empty; PrimaryKeyId contactUid = PrimaryKeyId.Empty; if (ClientControl.ObjectType == OrganizationEntity.GetAssignedMetaClassName()) { orgUid = ClientControl.ObjectId; } else if (ClientControl.ObjectType == ContactEntity.GetAssignedMetaClassName()) { contactUid = ClientControl.ObjectId; } #endregion DataTable dt = new DataTable(); DataView dv = new DataView(); if ((_pc[_strPref + "ShowDocumentGroup"] != null && bool.Parse(_pc[_strPref + "ShowDocumentGroup"])) || (Request.QueryString["DocGroup"] != null && Request.QueryString["DocGroup"] == "Prj")) { dt = Document.GetListDocumentsByFilterGroupedByProject(projId, manId, resId, priority_id, status_id, keyword, genCategory_type, orgUid, contactUid); dv = dt.DefaultView; } else if ((_pc[_strPref + "ShowDocumentGroup"] != null && bool.Parse(_pc[_strPref + "ShowDocumentGroup"])) || (Request.QueryString["DocGroup"] != null && Request.QueryString["DocGroup"] == "Client")) { dt = Document.GetListDocumentsByFilterGroupedByClient(projId, manId, resId, priority_id, status_id, keyword, genCategory_type, orgUid, contactUid); dv = dt.DefaultView; } else { dt = Document.GetListDocumentsByFilterDataTable(projId, manId, resId, priority_id, status_id, keyword, genCategory_type, contactUid, orgUid); dv = dt.DefaultView; if (_pc[_strPref + "DocumentList_SortColumn"] == null) { _pc[_strPref + "DocumentList_SortColumn"] = "CreationDate DESC"; } try { dv.Sort = _pc[_strPref + "DocumentList_SortColumn"]; } catch { } } dg.DataSource = dv; if (_pc[_strPref + "DocumentList_PageSize"] != null) { dg.PageSize = int.Parse(_pc[_strPref + "DocumentList_PageSize"]); } if (_pc[_strPref + "DocumentList_Page"] != null) { int pageIndex = int.Parse(_pc[_strPref + "DocumentList_Page"]); int ppi = dv.Count / dg.PageSize; if (dv.Count % dg.PageSize == 0) { ppi = ppi - 1; } if (pageIndex <= ppi) { dg.CurrentPageIndex = pageIndex; } else { dg.CurrentPageIndex = 0; } } dg.DataBind(); return(dt); }
override protected void Page_Load(object sender, System.EventArgs e) { if (Session[SessionKey.PatientId] != null && Session[SessionKey.PatientId].ToString().Length > 0) { int patientID = (int)Session[SessionKey.PatientId]; SecurityController sc = new SecurityController(); string userName = sc.GetUserName(); reportTitle = "Patient Summary Report"; patientName = Session[SessionKey.PtFirstName].ToString() + " " + Session[SessionKey.PtLastName].ToString() + " MRN: " + Session[SessionKey.PtMRN].ToString() + " " + System.DateTime.Now; //Narrator //Narrative narrative = new Narrative(); //narrative.GetByParent(patientID); DataView narrative = BusinessObject.GetByParentAsDataView <Narrative>(patientID); //narrative.DataSourceView.Sort = "EnteredTime DESC"; narrative.Sort = "EnteredTime DESC"; //rptNarrator.DataSource = narrative.DataSourceView; rptNarrator.DataSource = narrative; rptNarrator.DataBind(); //Allergies //Allergy allergy = new Allergy(); //allergy.GetByParent(patientID); //rptAllergies.DataSource = allergy.DataSourceView; rptAllergies.DataSource = BusinessObject.GetByParentAsDataView <Allergy>(patientID); rptAllergies.DataBind(); //Medications //Medication med = new Medication(); //med.GetByParent(patientID); //rptMedications.DataSource = med.DataSourceView; rptMedications.DataSource = BusinessObject.GetByParentAsDataView <Medication>(patientID); rptMedications.DataBind(); //Comorbidities //Comorbidity com = new Comorbidity(); //com.GetByParent(patientID); //rptComorbidities.DataSource = com.DataSourceView; rptComorbidities.DataSource = BusinessObject.GetByParentAsDataView <Comorbidity>(patientID); rptComorbidities.DataBind(); //HPI SUmmary try { PatientDa hpiDa = new PatientDa(); DataSet hpiDs = hpiDa.GetPatientHPI(patientID, 0, 0); //DataSet hpiDs = DataAccessHelper.GetList(phiCom); rptHPI.DataSource = hpiDs.Tables[0].DefaultView; rptHPI.DataBind(); } catch (Exception ex) { ExceptionHandler.Publish(ex); } //nomograms are in a second result set //base.preRPNomo.Text = hpiDs.Tables[1].Rows[0]["preRPNomo"].ToString(); //base.preXRTNomo.Text = hpiDs.Tables[1].Rows[0]["preXRTNomo"].ToString(); //base.preBrachyNomo.Text = hpiDs.Tables[1].Rows[0]["preBrachyNomo"].ToString(); //postRP2yrNomo.Text = hpiDs.Tables[1].Rows[0]["postRP2yrNomo"].ToString(); //postRP5yrNomo.Text = hpiDs.Tables[1].Rows[0]["postRP5yrNomo"].ToString(); //base.postRP7yrNomo.Text = hpiDs.Tables[1].Rows[0]["postRP7yrNomo"].ToString(); NomogramDa nda = new NomogramDa(); try { preRP5Nomo.Text = ((int)Math.Round(nda.GetPreRPResult(patientID, 5), 0)).ToString(); } catch { } try { preRP10Nomo.Text = ((int)Math.Round(nda.GetPreRPResult(patientID, 10), 0)).ToString(); } catch { } try { preXRTNomo.Text = ((int)Math.Round(nda.GetPreXRTResult(patientID), 0)).ToString(); } catch { } try { preBrachyNomo.Text = ((int)Math.Round(nda.GetPreBrachyResult(patientID), 0)).ToString(); } catch { } try { postRP2yrNomo.Text = ((int)Math.Round(nda.GetPostRPResult(patientID, 2), 0)).ToString(); } catch { } try { postRP5yrNomo.Text = ((int)Math.Round(nda.GetPostRPResult(patientID, 5), 0)).ToString(); } catch { } try { postRP7yrNomo.Text = ((int)Math.Round(nda.GetPostRPResult(patientID, 7), 0)).ToString(); } catch { } try { postRP10yrNomo.Text = ((int)Math.Round(nda.GetPostRPResult(patientID, 10), 0)).ToString(); } catch { } //Chron List: displays most relevant/common list ChronoDa da = new ChronoDa(); DataSet ds = da.GetChronoList(patientID, chronListName, HttpContext.Current.User.Identity.Name); rptChrono.DataSource = ds.Tables[0].DefaultView; rptChrono.DataBind(); recordCount = ds.Tables[0].Rows.Count; BuildChart(); } }
private void btnLoad_Click(object sender, EventArgs e) { CustomersTable = CreateDataSet.DataSetFiller.FillDataset(dataFilePath).Tables["Customers"]; CustomersView = new DataView(CustomersTable); dgView.DataSource = CustomersView; }
private void RefreshObjectsList() { bool isFirstConditionAdded = false; StringBuilder condition = new StringBuilder(); for (int i = 0; i < tableLayoutPanel1.Controls.Count; i++) { Control ctrl = tableLayoutPanel1.Controls[i]; if (ctrl.GetType() == typeof(CheckBox)) { if (((CheckBox)ctrl).Checked) { if (!isFirstConditionAdded) { condition.Append("Type='" + ctrl.Tag.ToString() + "'"); isFirstConditionAdded = true; } else { condition.Append(" OR Type='" + ctrl.Tag.ToString() + "'"); } } } } DataView dwObjects = new DataView(dbOjects, condition.ToString(), "Type,Name", DataViewRowState.CurrentRows); lwDatabaseObjects.Items.Clear(); lwDatabaseObjects.Groups.Clear(); lwDatabaseObjects.Groups.Add("1", "Objects that exist only in " + Database1 + " "); lwDatabaseObjects.Groups.Add("2", "Objects that exist only in " + Database2 + " "); lwDatabaseObjects.Groups.Add("3", "Objects that exist in both databases and are identical"); lwDatabaseObjects.Groups.Add("4", "Objects that exist in both databases and are different"); foreach (DataRowView dr in dwObjects) { int imgIndex = 0; switch (dr["Type"].ToString().ToUpper()) { //fullTextIndex case "STOREDPROCEDURE": imgIndex = 0; break; case "TABLE": imgIndex = 1; break; case "SQLUSERDEFINEDFUNCTION": imgIndex = 31; break; case "SQLUSERDEFINEDTABLEFUNCTION": imgIndex = 30; break; case "VIEW": imgIndex = 3; break; case "APPLICATIONROLE": imgIndex = 4; break; case "DATABASEROLE": imgIndex = 5; break; case "DEFAULT": imgIndex = 6; break; case "FULLTEXTCATALOG": imgIndex = 7; break; case "FULLTEXTSTOPLIST": imgIndex = 7; break; case "USERDEFINEDTABLETYPE": imgIndex = 1; break; case "MESSAGETYPE": imgIndex = 8; break; case "PARTITIONFUNCTION": imgIndex = 9; break; case "PARTITIONSCHEME": imgIndex = 10; break; case "PLANGUIDE": imgIndex = 12; break; case "REMOTESERVICEBINDING": imgIndex = 15; break; case "RULE": imgIndex = 13; break; case "SCHEMA": imgIndex = 14; break; case "SERVICECONTRACT": imgIndex = 16; break; case "SERVICEQUEUE": imgIndex = 17; break; case "SERVICEROUTE": imgIndex = 18; break; case "SQLASSEMBLY": imgIndex = 19; break; case "SQLDDLTRIGGER": imgIndex = 20; break; case "CLRDDLTRIGGER": imgIndex = 20; break; case "SYNONYM": imgIndex = 21; break; case "USER": imgIndex = 22; break; case "AGGREGATE": imgIndex = 23; break; case "USERDEFINEDTYPE": imgIndex = 24; break; case "USERDEFINEDDATATYPE": imgIndex = 25; break; case "XMLSCHEMACOLLECTION": imgIndex = 26; break; case "SQLDMLTRIGGER": imgIndex = 27; break; case "CLRDMLTRIGGER": imgIndex = 27; break; case "INDEX": imgIndex = 28; break; case "SERVICE": imgIndex = 29; break; case "CLRUSERDEFINEDFUNCTION": imgIndex = 31; break; case "CLRUSERDEFINEDTABLEFUNCTION": imgIndex = 30; break; case "CLRTrigger": imgIndex = 20; break; /* * case "USERDEFINEDTABLETYPE": * imgIndex = 1; * break;*/ } switch (dr["ResultSet"].ToString()) { case "1": this.lwDatabaseObjects.Items.Add(new ListViewItem(new string[] { dr["Type"].ToString(), dr["Schema"].ToString(), dr["Name"].ToString() }, imgIndex, lwDatabaseObjects.Groups[0])); break; case "2": this.lwDatabaseObjects.Items.Add(new ListViewItem(new string[] { dr["Type"].ToString(), dr["Schema"].ToString(), dr["Name"].ToString() }, imgIndex, lwDatabaseObjects.Groups[1])); break; case "3": this.lwDatabaseObjects.Items.Add(new ListViewItem(new string[] { dr["Type"].ToString(), dr["Schema"].ToString(), dr["Name"].ToString() }, imgIndex, lwDatabaseObjects.Groups[2])); break; case "4": this.lwDatabaseObjects.Items.Add(new ListViewItem(new string[] { dr["Type"].ToString(), dr["Schema"].ToString(), dr["Name"].ToString() }, imgIndex, lwDatabaseObjects.Groups[3])); break; } } }
public DataView getTareasAsignatura(DataSet dt, string codAsig) { DataView view = new DataView(dt.Tables[0]); view.RowFilter = "CodAsig ='" + codAsig + "'"; return view; }
private void GetData(string id) { if (String.IsNullOrEmpty(id)) { return; } DataView dv = Conn.Select(string.Format("Select * From MR_School Where SchoolID = '" + id + "'")); if (dv.Count != 0) { txtSchoolID.Text = dv[0]["SchoolNo"].ToString(); txtSchoolName.Text = dv[0]["SchoolName"].ToString(); txtAddress.Text = dv[0]["Address"].ToString(); ddlProvince.SelectedValue = dv[0]["ProvinceID"].ToString(); txtTel.Text = dv[0]["Tel"].ToString(); txtFax.Text = dv[0]["Fax"].ToString(); txtArea.Text = dv[0]["strTotalArea"].ToString(); cbPrimary.Checked = Convert.ToBoolean(dv[0]["IsPrimaryEdu"]); cbSecondary.Checked = Convert.ToBoolean(dv[0]["IsSecondary"]); cbHighSchool.Checked = Convert.ToBoolean(dv[0]["IsHighSc"]); txtAreaOfStudy.Text = dv[0]["AreaStudyID"].ToString(); txtDateBegin.Text = Convert.ToDateTime(dv[0]["BirthDate"]).ToShortDateString(); ddlSDay.SelectedValue = Convert.ToDateTime(dv[0]["BirthDate"]).Day.ToString("00"); ddlSMonth.SelectedValue = Convert.ToDateTime(dv[0]["BirthDate"]).Month.ToString("00"); ddlSYear.SelectedValue = (Convert.ToDateTime(dv[0]["BirthDate"]).Year + 543).ToString(); txtSchoolColor.Text = dv[0]["SchoolColor"].ToString(); txtPhilosophy.Text = dv[0]["Philosophy"].ToString(); txtSlogan.Text = dv[0]["Slogan"].ToString(); txtPolicy.Text = dv[0]["Policy"].ToString(); txtHistory.Text = dv[0]["History"].ToString(); txtManagerPlanName.Text = dv[0]["ManagerPlanName"].ToString(); txtPositionPlanName.Text = dv[0]["PositionPlanName"].ToString(); txtManagerSuppliesName.Text = dv[0]["ManagerSuppliesName"].ToString(); txtPositionSuppliesName.Text = dv[0]["PositionSuppliesName"].ToString(); txtManagerMoneyName.Text = dv[0]["ManagerMoneyName"].ToString(); txtPositionMoneyName.Text = dv[0]["PositionMoneyName"].ToString(); txtUnderBudgetName.Text = dv[0]["UnderBudgetName"].ToString(); txtPositionManagerBudgetName.Text = dv[0]["PositionManagerBudgetName"].ToString(); txtUnderManagerName.Text = dv[0]["UnderManagerName"].ToString(); txtPositionUnderManagerName.Text = dv[0]["PositionUnderManagerName"].ToString(); //txtDeputyDirectorName.Text = dv[0]["DeputyDirectorName"].ToString(); //txtPositionDeputyDirector.Text = dv[0]["PositionDeputyDirector"].ToString(); txtGroupLeaderPlanName.Text = dv[0]["GroupLeaderPlanName"].ToString(); txtPositionGroupLeaderPlan.Text = dv[0]["PositionGroupLeaderPlan"].ToString(); string strSql = " Select DeputyDirectorID, DeputyDirectorName, DeputyDirectorPosition, Sort As id " + " From DeputyDirector " + " Where SchoolID = '{0}' "; dvDeputyDirector = Conn.Select(string.Format(strSql + " Order By Sort ", id)); if (dvDeputyDirector.Count != 0) { btDelDeputyDirector.Visible = true; if (Session["DeputyDirector"] == null) { DataTable dt1 = new DataTable(); dt1.Columns.Add("id"); dt1.Columns.Add("DeputyDirectorName"); dt1.Columns.Add("DeputyDirectorPosition"); DataRow dr; for (int i = 0; i < dvDeputyDirector.Count; i++) { dr = dt1.NewRow(); dr["id"] = dvDeputyDirector[i]["id"].ToString(); dr["DeputyDirectorName"] = dvDeputyDirector[i]["DeputyDirectorName"].ToString(); dr["DeputyDirectorPosition"] = dvDeputyDirector[i]["DeputyDirectorPosition"].ToString(); dt1.Rows.Add(dr); } dvDeputyDirector = dt1.DefaultView; Session["DeputyDirector"] = dt1; } GridViewDeputyDirector.Visible = true; GridViewDeputyDirector.DataSource = dvDeputyDirector; GridViewDeputyDirector.CheckListDataField = "id"; GridViewDeputyDirector.DataBind(); } else { btDelDeputyDirector.Visible = false; GridViewDeputyDirector.Visible = false; } //ddlYearS.SelectedValue = dv[0]["StudyYear"].ToString(); getMission(ddlYearS.SelectedValue); getGoals(ddlYearS.SelectedValue); getStrategies(ddlYearS.SelectedValue); txtIdentity.Text = dv[0]["IdentityName"].ToString(); txtIdentity2.Text = dv[0]["IdentityName2"].ToString(); txtVision.Text = dv[0]["Vision"].ToString(); txtManagerName.Text = dv[0]["ManagerName"].ToString(); txtPositionManagerName.Text = dv[0]["PositionManagerName"].ToString(); if (!string.IsNullOrEmpty(dv[0]["LogoPath"].ToString())) { imgPicture.ImageUrl = dv[0]["LogoPath"].ToString(); ImgBt.Visible = true; } else { imgPicture.ImageUrl = "../Image/Menu9.png"; ImgBt.Visible = false; } if (btc.ckGetAdmission(CurrentUser.UserRoleID) != 1) { btSave.Visible = false; fiUpload.Visible = false; btnUpload.Visible = false; ImgBt.Visible = false; } else { btSave.Visible = true; fiUpload.Visible = true; btnUpload.Visible = true; } } }
/// <summary> /// The import_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void import_Click([NotNull] object sender, [NotNull] EventArgs e) { if (long.Parse(this.File.SelectedValue) < 1) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_SMILIES_IMPORT", "ERROR_SELECT_FILE")); return; } string fileName = this.Request.MapPath( "{0}{1}/{2}".FormatWith( YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Emoticons, this.File.SelectedItem.Text)); string split = Regex.Escape("=+:"); using (var file = new StreamReader(fileName)) { int sortOrder = 1; // Delete existing smilies? if (this.DeleteExisting.Checked) { this.GetRepository <Smiley>().Delete(); } else { // Get max value of SortOrder using (DataView dv = this.GetRepository <Smiley>().ListUnique().DefaultView) { dv.Sort = "SortOrder desc"; if (dv.Count > 0) { DataRowView dr = dv[0]; if (dr != null) { object o = dr["SortOrder"]; if (int.TryParse(o.ToString(), out sortOrder)) { sortOrder++; } } } } } do { string line = file.ReadLine(); if (line == null) { break; } string[] lineSplit = Regex.Split(line, split, RegexOptions.None); if (lineSplit.Length != 3) { continue; } this.GetRepository <Smiley>().Save(null, lineSplit[2], lineSplit[0], lineSplit[1], (byte)sortOrder, 0); sortOrder++; }while (true); file.Close(); } YafBuildLink.Redirect(ForumPages.admin_smilies); }
internal static void assignAllowFromDataView(Dictionary <string, bool> permsDict, DataView permsView) { foreach (DataRowView row in permsView) { //Get the action code and allow bit string actionCode = row["ActionCode"].ToString(); bool allowBit = Convert.ToBoolean(row["Allow"]); //If the current actioncode is denied, we will not ever allow if (permsDict.ContainsKey(actionCode) && !(permsDict[actionCode])) { continue; } else //Set the allow bit { permsDict[actionCode] = allowBit; } } }
public DataTable ObtenerReporteBaseDatos(String ID_OCUPACION, String NIV_EDUCACION, String PROFESION, String AREA_INTERES_LABORAL, String EXPERIENCIA, String EDAD_DESDE, String EDAD_HASTA, String ID_CIUDAD, String NOMBRES, String APELLIDOS, String BARRIO, String ASPIRACION_DESDE, String ASPIRACION_HASTA, String FECHA_ACTUALIZACION_DESDE, String FECHA_ACTUALIZACION_HASTA, String PALABRA_CLAVE, String TIPO_REPORTE) { Conexion conexion = new Conexion(Empresa); DataSet _dataSet = new DataSet(); DataView _dataView = new DataView(); DataTable _dataTable = new DataTable(); String sql = null; Boolean ejecutar = true; sql = "usp_base_de_datos_obtener_por_filtros "; if (String.IsNullOrEmpty(ID_OCUPACION) == false) { sql += ID_OCUPACION + ", "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(NIV_EDUCACION) == false) { sql += NIV_EDUCACION + ", "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(PROFESION) == false) { sql += "'" + PROFESION + "', "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(AREA_INTERES_LABORAL) == false) { sql += AREA_INTERES_LABORAL + ", "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(EXPERIENCIA) == false) { sql += "'" + EXPERIENCIA + "', "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(EDAD_DESDE) == false) { sql += EDAD_DESDE + ", "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(EDAD_HASTA) == false) { sql += EDAD_HASTA + ", "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(ID_CIUDAD) == false) { sql += "'" + ID_CIUDAD + "', "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(NOMBRES) == false) { sql += "'" + NOMBRES + "', "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(APELLIDOS) == false) { sql += "'" + APELLIDOS + "', "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(BARRIO) == false) { sql += "'" + BARRIO + "', "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(ASPIRACION_DESDE) == false) { sql += ASPIRACION_DESDE + ", "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(ASPIRACION_HASTA) == false) { sql += ASPIRACION_HASTA + ", "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(FECHA_ACTUALIZACION_DESDE) == false) { sql += "'" + FECHA_ACTUALIZACION_DESDE + "', "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(FECHA_ACTUALIZACION_HASTA) == false) { sql += "'" + FECHA_ACTUALIZACION_HASTA + "', "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(PALABRA_CLAVE) == false) { sql += "'" + PALABRA_CLAVE + "', "; } else { sql += "NULL, "; } if (String.IsNullOrEmpty(TIPO_REPORTE) == false) { sql += "'" + TIPO_REPORTE + "'"; } else { ejecutar = false; MensajeError = "El Campo TIPO DE REPORTE no puede ser nulo."; } if (ejecutar) { try { _dataSet = conexion.ExecuteReader(sql); _dataView = _dataSet.Tables[0].DefaultView; _dataTable = _dataView.Table; } catch (Exception e) { MensajeError = e.Message; } finally { conexion.Desconectar(); } } return(_dataTable); }
/// <summary> /// Computes the similarity of two scanpaths s and t. Fixation sites are /// defined using x and y coordinates. /// </summary> /// <param name="fixationsOfS">A <see cref="DataView"/> with the fixations of the first path.</param> /// <param name="fixationsOfT">A <see cref="DataView"/> with the fixations of the second path.</param> /// <param name="modulator">For an explanation of modulator see the poster.</param> /// <returns>The similarity of two scanpaths s and t</returns> /// <remarks> Die Koordinate sind in Graden des Gesichtsfelds angegeben, /// Pixel-Koordinaten vom Tracker müssen also vorher projeziert werden. /// </remarks> public static float MalsburgDistance( DataView fixationsOfS, DataView fixationsOfT, float modulator) { // Number of fixations equals string length int n = fixationsOfS.Count; int m = fixationsOfT.Count; // Creates and initializes a new two-dimensional Array of type double. double[,] d = new double[n + 1, m + 1]; // Iterate fixations for (int i = 0; i < n; i++) { DataRow fixationRowOfS = fixationsOfS[i].Row; float sX = !fixationRowOfS.IsNull("PosX") ? Convert.ToSingle(fixationRowOfS["PosX"]) : 0; float sY = !fixationRowOfS.IsNull("PosY") ? Convert.ToSingle(fixationRowOfS["PosY"]) : 0; int durationOfS = (int)fixationRowOfS["Length"]; for (int j = 0; j < m; j++) { DataRow fixationRowOfT = fixationsOfT[j].Row; float tX = !fixationRowOfT.IsNull("PosX") ? Convert.ToSingle(fixationRowOfT["PosX"]) : 0; float tY = !fixationRowOfT.IsNull("PosY") ? Convert.ToSingle(fixationRowOfT["PosY"]) : 0; int durationOfT = (int)fixationRowOfT["Length"]; ////* Great circle distance using the Vincenty formula for better //// * precision: */ ////double d_lon = sFixations[i].PosX.Value - tFixations[j].PosX.Value; ////double cos_d_lon = Math.Cos(d_lon); ////double sin_d_lon = Math.Sin(d_lon); ////double cos_slat = Math.Cos(sFixations[i].PosY.Value); ////double cos_tlat = Math.Cos(tFixations[j].PosY.Value); ////double sin_slat = Math.Sin(sFixations[i].PosY.Value); ////double sin_tlat = Math.Sin(tFixations[j].PosY.Value); ////double distance = Math.Atan2(Math.Sqrt(Math.Pow(cos_tlat * Math.Sin(d_lon), 2) //// + Math.Pow(cos_slat * sin_tlat - sin_slat * cos_tlat * cos_d_lon, 2)), //// sin_slat * sin_tlat + cos_slat * cos_tlat * cos_d_lon); ////distance *= 180 / Math.PI; double distance = Math.Sqrt(Math.Pow(tX - sX, 2) + Math.Pow(tY - sY, 2)); /* cortical magnification */ distance = Math.Pow(modulator, distance); /* cost for substituting */ double cost = Math.Abs((durationOfT - durationOfS) * distance) + (durationOfT + durationOfS) * (1.0 - distance); /* selection of edit operation */ d[i + 1, j + 1] = Math.Min( d[i, j + 1] + durationOfS, Math.Min(d[i + 1, j] + durationOfT, d[i, j] + cost)); } } float result = (float)d[n, m]; result /= n + m; return(result); }
protected void btngo_Click(object sender, EventArgs e) { try { string valCollege = string.Empty; int exMonthName = 0; int colspanbranch = 0; int colspansubj = 0; int coldeg = 0; int coldegr = 0; int dsrow = 0; int inrow = 0; string sess = string.Empty; string collegeCode1 = string.Empty; int total = 0; bool colspanBool = false; string BranchCodeReplication = string.Empty; string degree = string.Empty; string subjcode = string.Empty; DataView colSpanDV = new DataView(); DataView colSpansub = new DataView(); DataSet dsCollege = new DataSet(); Fpspread.Sheets[0].Visible = true; Fpspread.Sheets[0].AutoPostBack = true; Fpspread.Sheets[0].RowHeader.Visible = false; Fpspread.Sheets[0].ColumnHeader.Visible = true; MyStyle.Font.Size = FontUnit.Medium; MyStyle.Font.Name = "Book Antiqua"; MyStyle.Font.Bold = true; MyStyle.HorizontalAlign = HorizontalAlign.Center; MyStyle.ForeColor = Color.White; MyStyle.BackColor = ColorTranslator.FromHtml("#0CA6CA"); Fpspread.Sheets[0].ColumnHeader.DefaultStyle = MyStyle; Fpspread.CommandBar.Visible = false; Fpspread.Sheets[0].ColumnCount = 8; Fpspread.Sheets[0].RowCount = 2; Fpspread.BorderWidth = 2; valCollege = rs.GetSelectedItemsValueAsString(cblCollege); btn_directprint.Visible = true; if (valCollege.ToString() != "") { if (ddlDate.SelectedValue != "" && ddlSession.SelectedValue != "") { lblerror.Visible = false; Fpspread.Visible = true; int.TryParse(Convert.ToString(ddlMonth.SelectedValue).Trim(), out exMonthName); string exdate = Convert.ToString(ddlDate.SelectedValue).Trim(); string[] spl1 = exdate.Split('-'); DateTime dtl1 = Convert.ToDateTime(spl1[1] + '-' + spl1[0] + '-' + spl1[2]); string exmdate = dtl1.ToString("dd"); string exmmonth = dtl1.ToString("MM"); string exmmonthful = dtl1.ToString("MMMM"); string exmyear = dtl1.ToString("yyyy"); string examdate = exmyear + '-' + exmmonth + '-' + exmdate; string prmonthyea = exmmonthful + '-' + exmyear; // string sql ="select distinct s.subject_code, de.Dept_Name,c.Course_Name,d.Degree_Code,s.subject_name,d.Acronym,et.exam_date,et.exam_session from exmtt e,exmtt_det et,course c,Degree d,Department de,subject s where e.degree_code=d.Degree_Code and c.Course_Id=d.Course_Id and d.Dept_Code=de.Dept_Code and et.exam_date='" + examdate + "' and e.exam_Month='" + exMonthName + "' and e.Exam_Year='" + ddlYear.SelectedItem.Text + "' and et.exam_session='" + ddlSession.SelectedItem.Text + "' and et.coll_code in('" + valCollege + "')and e.exam_code=et.exam_code and et.subject_no=s.subject_no group by c.Course_Name, de.Dept_Name,d.Degree_Code,s.subject_name,d.Acronym,et.exam_date,et.exam_session,s.subject_code order by de.Dept_Name"; //string sql = "select distinct s.subject_code,de.Dept_Name,c.Course_Name,s.subject_name,et.exam_date,et.exam_session,d.Acronym,COUNT(ea.roll_no) as stucount from Exam_Details e,exam_application ea,exam_appl_details ed,subject s,exmtt_det et, Registration r,Degree d,course c,Department de where e.exam_code=ea.exam_code and ea.appl_no=ed.appl_no and ed.subject_no=s.subject_no and s.subject_no=et.subject_no and ea.roll_no =r.Roll_No and r.degree_code=d.Degree_Code and d.Dept_Code=de.Dept_Code and d.Course_Id=c.Course_Id and e.Exam_Month='" + exMonthName + "'and et.coll_code in('" + valCollege + "') and e.Exam_year='" + ddlYear.SelectedItem.Text + "' and et.exam_date='" + examdate + "' and et.exam_session='" + ddlSession.SelectedItem.Text + "' group by s.subject_code,de.Dept_Name,c.Course_Name,s.subject_name,et.exam_date,et.exam_session,d.Acronym,c.type order by de.Dept_Name"; string sql = "select s.subject_code,(c.Course_Name+'-'+de.Dept_Name) as course,c.Edu_Level,s.subject_name,et.exam_date,et.exam_session,d.Acronym,COUNT(ea.roll_no) as stucount from Exam_Details e,exam_application ea,exam_appl_details ed,subject s,exmtt_det et, Registration r,Degree d,course c,Department de where e.exam_code=ea.exam_code and ea.appl_no=ed.appl_no and ed.subject_no=s.subject_no and s.subject_no=et.subject_no and ea.roll_no =r.Roll_No and r.degree_code=d.Degree_Code and d.Dept_Code=de.Dept_Code and d.Course_Id=c.Course_Id and e.Exam_Month='" + exMonthName + "' and et.coll_code in('" + valCollege + "') and e.Exam_year='" + ddlYear.SelectedItem.Text + "' and et.exam_date='" + examdate + "' and et.exam_session='" + ddlSession.SelectedItem.Text + "' group by s.subject_code,de.Dept_Name,c.Course_Name,s.subject_name,et.exam_date,et.exam_session,d.Acronym,c.Edu_Level,c.type order by s.subject_code"; ds = dt.select_method_wo_parameter(sql, "text"); int tabrow = ds.Tables[0].Rows.Count; if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { Fpspread.Sheets[0].RowCount = 0; for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { Fpspread.Sheets[0].RowCount++; Fpspread.Sheets[0].ColumnHeader.Cells[0, 0].Text = "Date of Exam"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 0].Font.Bold = true; Fpspread.Sheets[0].ColumnHeader.Cells[0, 0].Font.Name = "Book Antiqua"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 0].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].ColumnHeader.Cells[0, 0].HorizontalAlign = HorizontalAlign.Center; Fpspread.Columns[0].Width = 50; Fpspread.Sheets[0].ColumnHeader.Cells[0, 1].Text = "Session"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 1].Font.Bold = true; Fpspread.Sheets[0].ColumnHeader.Cells[0, 1].Font.Name = "Book Antiqua"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 1].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].ColumnHeader.Cells[0, 1].HorizontalAlign = HorizontalAlign.Center; Fpspread.Columns[1].Width = 50; Fpspread.Sheets[0].ColumnHeader.Cells[0, 2].Text = "Subject Code"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 2].Font.Bold = true; Fpspread.Sheets[0].ColumnHeader.Cells[0, 2].Font.Name = "Book Antiqua"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 2].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].ColumnHeader.Cells[0, 2].HorizontalAlign = HorizontalAlign.Center; Fpspread.Columns[1].Width = 50; string subj = Convert.ToString(ds.Tables[0].Rows[j]["subject_code"]).Trim(); string subjname = Convert.ToString(ds.Tables[0].Rows[j]["subject_name"]).Trim(); Fpspread.Sheets[0].ColumnHeader.Cells[0, 3].Text = "Branch"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 3].Font.Bold = true; Fpspread.Sheets[0].ColumnHeader.Cells[0, 3].Font.Name = "Book Antiqua"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 3].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].ColumnHeader.Cells[0, 3].HorizontalAlign = HorizontalAlign.Center; Fpspread.Columns[1].Width = 50; string edulevel = Convert.ToString(ds.Tables[0].Rows[j]["Edu_Level"]).Trim(); ds.Tables[0].DefaultView.RowFilter = " Edu_Level='" + Convert.ToString(ds.Tables[0].Rows[j]["Edu_Level"]) + "' "; if (!hat.ContainsKey(edulevel)) { hat.Add(edulevel, subjname); Spdegree.InnerHtml = "DEGREE: " + edulevel + ""; } string bran = Convert.ToString(ds.Tables[0].Rows[j]["course"]).Trim(); ds.Tables[0].DefaultView.RowFilter = " course='" + Convert.ToString(ds.Tables[0].Rows[j]["course"]) + "' "; colSpanDV = ds.Tables[0].DefaultView; if (BranchCodeReplication != Convert.ToString(ds.Tables[0].Rows[j]["course"])) { Fpspread.Sheets[0].Cells[j, 3].Text = Convert.ToString(bran).Trim(); Fpspread.Sheets[0].Cells[j, 3].VerticalAlign = VerticalAlign.Middle; Fpspread.Sheets[0].Cells[j, 3].HorizontalAlign = HorizontalAlign.Left; if (BranchCodeReplication != "") { if (colSpanDV.Count > 0) { Fpspread.Sheets[0].SpanModel.Add(Fpspread.Sheets[0].RowCount - colspanbranch - 1, 3, colspanbranch, 1); } } colspanbranch = 0; } colspanbranch++; BranchCodeReplication = Convert.ToString(ds.Tables[0].Rows[j]["course"]).Trim(); Fpspread.Sheets[0].ColumnHeader.Cells[0, 4].Text = "Q.P Code/Booklet code"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 4].Font.Bold = true; Fpspread.Sheets[0].ColumnHeader.Cells[0, 4].Font.Name = "Book Antiqua"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 4].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].ColumnHeader.Cells[0, 4].HorizontalAlign = HorizontalAlign.Center; Fpspread.Columns[1].Width = 50; Fpspread.Sheets[0].ColumnHeader.Cells[0, 5].Text = "Answer Paper Packet Number Alloted by College"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 5].Font.Bold = true; Fpspread.Sheets[0].ColumnHeader.Cells[0, 5].Font.Name = "Book Antiqua"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 5].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].ColumnHeader.Cells[0, 5].HorizontalAlign = HorizontalAlign.Center; Fpspread.Columns[1].Width = 50; Fpspread.Sheets[0].ColumnHeader.Cells[0, 6].Text = "Subject"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 6].Font.Bold = true; Fpspread.Sheets[0].ColumnHeader.Cells[0, 6].Font.Name = "Book Antiqua"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 6].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].ColumnHeader.Cells[0, 6].HorizontalAlign = HorizontalAlign.Center; Fpspread.Columns[1].Width = 50; Fpspread.Sheets[0].ColumnHeader.Cells[0, 7].Text = "Total Answer scripts"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 7].Font.Bold = true; Fpspread.Sheets[0].ColumnHeader.Cells[0, 7].Font.Name = "Book Antiqua"; Fpspread.Sheets[0].ColumnHeader.Cells[0, 7].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].ColumnHeader.Cells[0, 7].HorizontalAlign = HorizontalAlign.Center; Fpspread.Columns[1].Width = 50; string strquery = "select *,district+' - '+pincode as districtpin from collinfo where college_code='" + Convert.ToString(Session["collegecode"]).Trim() + "'"; DataSet ds1 = new DataSet(); ds1.Dispose(); ds1.Reset(); ds1 = dt.select_method_wo_parameter(strquery, "Text"); spF1College.InnerText = ds1.Tables[0].Rows[0]["Collname"].ToString(); string catagor = ds1.Tables[0].Rows[0]["category"].ToString(); // string[] strpa = Convert.ToString(ds1.Tables[0].Rows[0]["affliatedby"]).Trim().Split(','); spcategory.InnerHtml = "(" + Convert.ToString(catagor).Trim() + " & " + Convert.ToString(ds1.Tables[0].Rows[0]["university"]).Trim() + ")"; spF1Date.InnerText = "Month & year of Exam: " + Convert.ToString(prmonthyea).Trim() + ""; spHead.InnerText = "DESPATCH OF ANSWER PACKETS "; dateoedel.InnerHtml = "Date of Delvery:" + Convert.ToString(ddlDate.SelectedValue).Trim() + ""; spsign.InnerHtml = "Signature of the Anna University Representative"; spsignchif.InnerHtml = "Signature of the Chief Superintendent"; spsig.InnerHtml = "Authorized Signatory office of COE"; spnbun.InnerHtml = "Received " + ds.Tables[0].Rows.Count + " bundles from exam cell"; ds.Tables[0].DefaultView.RowFilter = " subject_code='" + Convert.ToString(ds.Tables[0].Rows[j]["subject_code"]) + "' "; colSpansub = ds.Tables[0].DefaultView; if (subjcode != Convert.ToString(ds.Tables[0].Rows[j]["subject_code"])) { if (subjcode != "") { if (colSpansub.Count > 0) { dsrow = j; inrow = j; dsrow = ds.Tables[0].Rows.Count - 1; Fpspread.Sheets[0].SpanModel.Add(Fpspread.Sheets[0].RowCount - colspansubj - 1, 2, colspansubj, 1); Fpspread.Sheets[0].SpanModel.Add(Fpspread.Sheets[0].RowCount - colspansubj - 1, 6, colspansubj, 1); } } colspansubj = 0; } colspansubj++; if (dsrow == 0 && j == ds.Tables[0].Rows.Count - 1) { Fpspread.Sheets[0].SpanModel.Add(0, 2, ds.Tables[0].Rows.Count, 1); Fpspread.Sheets[0].SpanModel.Add(0, 6, ds.Tables[0].Rows.Count, 1); } if (dsrow == j) { Fpspread.Sheets[0].SpanModel.Add(inrow, 2, colspansubj, 1); Fpspread.Sheets[0].SpanModel.Add(inrow, 6, colspansubj, 1); } subjcode = Convert.ToString(ds.Tables[0].Rows[j]["subject_code"]).Trim(); if (!hat.ContainsKey(subj)) { hat.Add(subj, bran); Fpspread.Sheets[0].Cells[j, 2].Text = Convert.ToString(subj).Trim(); Fpspread.Sheets[0].Cells[j, 2].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].Cells[j, 2].VerticalAlign = VerticalAlign.Middle; Fpspread.Sheets[0].Cells[j, 2].HorizontalAlign = HorizontalAlign.Center; Fpspread.Sheets[0].Cells[j, 6].Text = Convert.ToString(subjname).Trim(); Fpspread.Sheets[0].Cells[j, 6].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].Cells[j, 6].VerticalAlign = VerticalAlign.Middle; Fpspread.Sheets[0].Cells[j, 6].HorizontalAlign = HorizontalAlign.Left; } Fpspread.Sheets[0].Cells[j, 7].Text = Convert.ToString(ds.Tables[0].Rows[j]["stucount"]).Trim(); Fpspread.Sheets[0].Cells[j, 7].HorizontalAlign = HorizontalAlign.Center; Fpspread.Sheets[0].Cells[j, 7].Font.Size = FontUnit.Medium; total += Convert.ToInt32(ds.Tables[0].Rows[j]["stucount"].ToString()); } Fpspread.Sheets[0].SpanModel.Add(0, 0, Fpspread.Sheets[0].RowCount, 1); Fpspread.Sheets[0].Cells[0, 0].Text = Convert.ToString(exdate).Trim(); Fpspread.Sheets[0].Cells[0, 0].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].Cells[0, 0].VerticalAlign = VerticalAlign.Middle; Fpspread.Sheets[0].Cells[0, 0].HorizontalAlign = HorizontalAlign.Center; Fpspread.Sheets[0].SpanModel.Add(0, 1, Fpspread.Sheets[0].RowCount, 1); Fpspread.Sheets[0].Cells[0, 1].Text = Convert.ToString(ddlSession.SelectedValue).Trim(); Fpspread.Sheets[0].Cells[0, 1].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].Cells[0, 1].VerticalAlign = VerticalAlign.Middle; Fpspread.Sheets[0].Cells[0, 1].HorizontalAlign = HorizontalAlign.Center; Fpspread.Sheets[0].RowCount++; Fpspread.Sheets[0].SpanModel.Add(Fpspread.Sheets[0].RowCount - 1, 0, 1, 5); Fpspread.Sheets[0].Cells[Fpspread.Sheets[0].RowCount - 1, 0].Text = "Total"; Fpspread.Sheets[0].Cells[Fpspread.Sheets[0].RowCount - 1, 7].Text = Convert.ToString(total).Trim(); Fpspread.Sheets[0].Cells[Fpspread.Sheets[0].RowCount - 1, 7].Font.Size = FontUnit.Medium; Fpspread.Sheets[0].Cells[Fpspread.Sheets[0].RowCount - 1, 7].HorizontalAlign = HorizontalAlign.Center; Fpspread.Sheets[0].Cells[Fpspread.Sheets[0].RowCount - 1, 0].HorizontalAlign = HorizontalAlign.Right; Fpspread.Sheets[0].RowCount++; Fpspread.Sheets[0].SpanModel.Add(Fpspread.Sheets[0].RowCount - 1, 0, 1, Fpspread.Sheets[0].Columns.Count); if (ddlSession.SelectedValue.Trim() == "A.N") { sess = "Afternoon"; } else { sess = "Forenoon"; } Fpspread.Sheets[0].Cells[Fpspread.Sheets[0].RowCount - 1, 0].Text = "1.Certificate of opening of sessionwise package of Q.P for " + sess + ""; Fpspread.Sheets[0].Cells[Fpspread.Sheets[0].RowCount - 1, 0].HorizontalAlign = HorizontalAlign.Left; Fpspread.Sheets[0].RowCount++; Fpspread.Sheets[0].SpanModel.Add(Fpspread.Sheets[0].RowCount - 1, 0, 1, Fpspread.Sheets[0].Columns.Count); Fpspread.Sheets[0].Cells[Fpspread.Sheets[0].RowCount - 1, 0].Text = "2.Student Attendance Sheet original copies for " + sess + ""; Fpspread.Sheets[0].Cells[Fpspread.Sheets[0].RowCount - 1, 0].HorizontalAlign = HorizontalAlign.Left; Fpspread.Sheets[0].PageSize = Fpspread.Sheets[0].RowCount; Fpspread.Width = 900; Fpspread.Height = 900; Fpspread.SaveChanges(); } else { lblerror.Text = "No Records Found"; lblerror.Visible = true; } } else { lblerror.Text = "Please select the date and session"; Fpspread.Visible = false; lblerror.Visible = true; btn_directprint.Visible = false; } } else { lblerror.Text = "Please select all field"; Fpspread.Visible = false; lblerror.Visible = true; btn_directprint.Visible = false; } } catch (Exception ex) { da.sendErrorMail(ex, collegeCode, "DespatchOfAnswerPackets"); } }
public DataReaderFake(DataView dados) : this(dados, 0) { }
private int AddHostingPlan(string name, int serverId) { try { Log.WriteStart("Adding hosting plan"); // gather form info HostingPlanInfo plan = new HostingPlanInfo(); plan.UserId = 1; plan.PlanId = 0; plan.IsAddon = false; plan.PlanName = name; plan.PlanDescription = ""; plan.Available = true; // always available plan.SetupPrice = 0; plan.RecurringPrice = 0; plan.RecurrenceLength = 1; plan.RecurrenceUnit = 2; // month plan.PackageId = 0; plan.ServerId = serverId; List <HostingPlanGroupInfo> groups = new List <HostingPlanGroupInfo>(); List <HostingPlanQuotaInfo> quotas = new List <HostingPlanQuotaInfo>(); DataSet ds = ES.Services.Packages.GetHostingPlanQuotas(-1, 0, serverId); foreach (DataRow groupRow in ds.Tables[0].Rows) { bool enabled = (bool)groupRow["ParentEnabled"]; if (!enabled) { continue; // disabled group } int groupId = (int)groupRow["GroupId"];; HostingPlanGroupInfo group = new HostingPlanGroupInfo(); group.GroupId = groupId; group.Enabled = true; group.CalculateDiskSpace = (bool)groupRow["CalculateDiskSpace"]; group.CalculateBandwidth = (bool)groupRow["CalculateBandwidth"]; groups.Add(group); DataView dvQuotas = new DataView(ds.Tables[1], "GroupID=" + group.GroupId.ToString(), "", DataViewRowState.CurrentRows); List <HostingPlanQuotaInfo> groupQuotas = GetGroupQuotas(groupId, dvQuotas); quotas.AddRange(groupQuotas); } plan.Groups = groups.ToArray(); plan.Quotas = quotas.ToArray(); int planId = ES.Services.Packages.AddHostingPlan(plan); if (planId > 0) { Log.WriteEnd("Added hosting plan"); } else { Log.WriteError(string.Format("Enterprise Server error: {0}", planId)); } return(planId); } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) { Log.WriteError("Hosting plan configuration error", ex); } return(-1); } }
private List <FreqEmitInfo> ShowDetail(DataSet ds, string pStatAppType) { List <FreqEmitInfo> freqEmitInfos = null; if (ds == null || ds.Tables.Count == 0) { return(freqEmitInfos); } #region 取数据 if (ds.Tables.Count > 0) { //频率表 if (ds.Tables["RSBT_FREQ"] != null && ds.Tables["RSBT_FREQ"].Rows.Count > 0) { freqEmitInfos = FreqInfoToEmit(ds.Tables["RSBT_FREQ"]); freqEmitInfos = freqEmitInfos.OrderBy(p => p.Guid).ToList(); } if (freqEmitInfos == null || freqEmitInfos.Count == 0) { return(freqEmitInfos); } //台站资料表 if (ds.Tables["RSBT_STATION"] != null && ds.Tables["RSBT_STATION"].Rows.Count > 0) { StationInfoToEmit(ds.Tables["RSBT_STATION"], ref freqEmitInfos); } //eaf对应关系ccode赋值 if (pStatAppType == "TF" || pStatAppType == "C" || pStatAppType == "E") { //频率冗余表 if (ds.Tables["RSBT_FREQ_T"] != null && ds.Tables["RSBT_FREQ_T"].Rows.Count > 0) { DataView dv = ds.Tables["RSBT_FREQ_T"].DefaultView; dv.Sort = "GUID"; Freq_TtoEmit(dv.ToTable(), ref freqEmitInfos, pStatAppType); } } //天线信息赋值 if (pStatAppType == "TF" || pStatAppType == "C") { //TF及C表的天线信息 if (ds.Tables["RSBT_ANTFEED"] != null && ds.Tables["RSBT_ANTFEED"].Rows.Count > 0 && ds.Tables["RSBT_ANTFEED_T"] != null && ds.Tables["RSBT_ANTFEED_T"].Rows.Count > 0) { CAndTFAntToEmit(ds.Tables["RSBT_ANTFEED"], ds.Tables["RSBT_ANTFEED_T"], ref freqEmitInfos, pStatAppType); } } else { //其他表天线赋值 if (ds.Tables["RSBT_ANTFEED"] != null && ds.Tables["RSBT_ANTFEED"].Rows.Count > 0) { AntToEmit(ds.Tables["RSBT_ANTFEED"], ref freqEmitInfos, pStatAppType); } } //设备功率信息赋值 if (pStatAppType != "E") { if (pStatAppType == "TF" || pStatAppType == "C") { //TF及C表设备功率信息 if (ds.Tables["RSBT_EQU"] != null && ds.Tables["RSBT_EQU"].Rows.Count > 0 && ds.Tables["RSBT_EQU_T"] != null && ds.Tables["RSBT_EQU_T"].Rows.Count > 0) { CAndTFEquToEmit(ds.Tables["RSBT_EQU"], ds.Tables["RSBT_EQU_T"], ref freqEmitInfos); } } else { //其他表设备功率 if (ds.Tables["RSBT_EQU"] != null && ds.Tables["RSBT_EQU"].Rows.Count > 0) { EquToEmit(ds.Tables["RSBT_EQU"], ref freqEmitInfos); } } } } #endregion return(freqEmitInfos); }
/// <summary> /// 绑定数据 /// </summary> public void bind() { //设置日期按钮状态 string dates = Convert.ToDateTime(tboxTimeB.Text).ToString("yyyy-MM-01"); DateTime dtb = Convert.ToDateTime(dates); DateTime dte = dtb.AddMonths(1).AddDays(-1); for (int i = -1; i <= 31; i++) { Control ctl = DateSelect.FindControl("btndateselect" + i); if (ctl != null && ctl.GetType() == typeof(Button)) { Button btn = (Button)ctl; if (i <= dte.Day && dtb.AddDays(i) <= DateTime.Now) { btn.Text = dtb.AddDays(i).ToString("MM-dd"); btn.Visible = true; if (btn.Text == Convert.ToDateTime(tboxTimeB.Text).ToString("MM-dd")) { btn.CssClass = "buttonblueo"; btn.Enabled = false; } else { btn.CssClass = "buttonblue"; btn.Enabled = true; } } else { btn.Visible = false; } } } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } if (DropDownListArea3.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea3.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToShortDateString() + " "; string sqlwhere = ""; sqlwhere += @" and F_Date='" + searchdateB.ToShortDateString() + "'"; if (DropDownListArea1.SelectedIndex > 0) { sqlwhere += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } if (DropDownListArea2.SelectedIndex > 0) { sqlwhere += @" and F_ZoneID=" + DropDownListArea2.SelectedValue.Split(',')[1] + ""; } string sql = ""; sql = @"SELECT top 100 ROW_NUMBER() OVER(order by sum(F_LoginNum) desc) AS rownum, max(F_BigZone) as F_BigZone, max(F_ZoneID) as F_ZoneID , Sum(F_LoginNum) as F_LoginNum, max(F_UserName) as F_UserName, max(F_LoginIP) as F_LoginIP from T_UserOnlineIPRank where 1=1 " + sqlwhere + " group by F_LoginIP"; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = "出错:" + ex.Message; //lblerro.Text = sql; } }
/// <summary> /// Calculate stats for a given data view and store them in a data row. /// </summary> /// <param name="row">The row to store the stats in.</param> /// <param name="columnNames">The column names to calculate stats for.</param> /// <param name="view">The data view to use.</param> private void CalculateStatsForDataView(DataRow row, List <string> columnNames, DataView view) { foreach (var columnName in columnNames) { var values = DataTableUtilities.GetColumnAsDoubles(view, columnName); if (CalcCount) { row[$"{ columnName}Count"] = values.Length; } if (CalcTotal) { row[$"{ columnName}Total"] = MathUtilities.Sum(values); } if (CalcMean) { row[$"{ columnName}Mean"] = MathUtilities.Average(values); } if (CalcMin) { row[$"{ columnName}Min"] = MathUtilities.Min(values); } if (CalcMax) { row[$"{ columnName}Max"] = MathUtilities.Max(values); } if (CalcStdDev) { row[$"{ columnName}StdDev"] = MathUtilities.SampleStandardDeviation(values); } if (CalcMedian) { row[$"{ columnName}Median"] = MathUtilities.Percentile(values, 0.5); } if (CalcPercentiles) { row[$"{ columnName}Percentile10"] = MathUtilities.Percentile(values, 0.1); row[$"{ columnName}Percentile20"] = MathUtilities.Percentile(values, 0.2); row[$"{ columnName}Percentile30"] = MathUtilities.Percentile(values, 0.3); row[$"{ columnName}Percentile40"] = MathUtilities.Percentile(values, 0.4); row[$"{ columnName}Percentile60"] = MathUtilities.Percentile(values, 0.6); row[$"{ columnName}Percentile70"] = MathUtilities.Percentile(values, 0.7); row[$"{ columnName}Percentile80"] = MathUtilities.Percentile(values, 0.8); row[$"{ columnName}Percentile90"] = MathUtilities.Percentile(values, 0.9); } } }
/// <summary>Main run method for performing our calculations and storing data.</summary> public void Run() { DataTable statsData = new DataTable(); DataTable simulationData = dataStore.Reader.GetData(this.TableName); if (simulationData != null) { if (FieldNamesToSplitOn != null && FieldNamesToSplitOn.Length != 0) { // Add the split fields to the stats table. foreach (var splitFieldName in FieldNamesToSplitOn) { if (!simulationData.Columns.Contains(splitFieldName)) { throw new Exception($"Cannot find field {splitFieldName} in table {simulationData.TableName}"); } var fieldType = simulationData.Columns[splitFieldName].DataType; statsData.Columns.Add(splitFieldName, fieldType); } } // Add required columns. var columnNames = new List <string>(); foreach (DataColumn column in simulationData.Columns) { if (column.DataType == typeof(double)) { if (CalcCount) { statsData.Columns.Add($"{ column.ColumnName}Count", typeof(int)); } if (CalcTotal) { statsData.Columns.Add($"{ column.ColumnName}Total", typeof(double)); } if (CalcMean) { statsData.Columns.Add($"{ column.ColumnName}Mean", typeof(double)); } if (CalcMin) { statsData.Columns.Add($"{ column.ColumnName}Min", typeof(double)); } if (CalcMax) { statsData.Columns.Add($"{ column.ColumnName}Max", typeof(double)); } if (CalcStdDev) { statsData.Columns.Add($"{ column.ColumnName}StdDev", typeof(double)); } if (CalcMedian) { statsData.Columns.Add($"{ column.ColumnName}Median", typeof(double)); } if (CalcPercentiles) { statsData.Columns.Add($"{ column.ColumnName}Percentile10", typeof(double)); statsData.Columns.Add($"{ column.ColumnName}Percentile20", typeof(double)); statsData.Columns.Add($"{ column.ColumnName}Percentile30", typeof(double)); statsData.Columns.Add($"{ column.ColumnName}Percentile40", typeof(double)); statsData.Columns.Add($"{ column.ColumnName}Percentile60", typeof(double)); statsData.Columns.Add($"{ column.ColumnName}Percentile70", typeof(double)); statsData.Columns.Add($"{ column.ColumnName}Percentile80", typeof(double)); statsData.Columns.Add($"{ column.ColumnName}Percentile90", typeof(double)); } columnNames.Add(column.ColumnName); } } DataView view = new DataView(simulationData); if (FieldNamesToSplitOn != null && FieldNamesToSplitOn.Length != 0) { var rowFilters = GetRowFilters(simulationData); foreach (var rowFilter in rowFilters) { view.RowFilter = rowFilter; if (view.Count > 0) { var newRow = statsData.NewRow(); // add in split fields. foreach (var splitFieldName in FieldNamesToSplitOn) { newRow[splitFieldName] = view[0][splitFieldName]; } // add in stats. CalculateStatsForDataView(newRow, columnNames, view); // add row to stats data table. statsData.Rows.Add(newRow); } } } else { // one row for the entire dataset. var newRow = statsData.NewRow(); CalculateStatsForDataView(newRow, columnNames, view); statsData.Rows.Add(newRow); } // Write the stats data to the DataStore statsData.TableName = this.Name; dataStore.Writer.WriteTable(statsData); } }
/// <summary> /// 将DataView对象转换成XML字符串 /// </summary> /// <param name="Dv">DataView对象</param> /// <returns>XML字符串</returns> public static string DataViewToXml(DataView Dv) { return(DataTableToXml(Dv.Table)); }
/// <summary> /// 将DataView对象转换成XML文件 /// </summary> /// <param name="Dv">DataView对象</param> /// <param name="XmlFilePath">xml文件路径</param> /// <returns>bool]值</returns> public static bool DataViewToXmlFile(DataView Dv, string XmlFilePath) { return(DataTableToXmlFile(Dv.Table, XmlFilePath)); }
protected void Page_Load(object sender, System.EventArgs e) { RegionCountriesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "select distinct Country,Region from Countries inner join Regions on Countries.RegionID=Regions.ID " + " inner join StateProvinces on StateProvinces.CountryID=Countries.ID " + "where (RegionID=@RegionID) AND EXISTS (" + " SELECT * FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID" + " WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1)" + " AND (Cities.StateProvinceID = StateProvinces.ID) " + " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) " + "ORDER BY Country", SqlDbType.Int); StateProvincesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT StateProvinces.* " + "FROM StateProvinces " + "WHERE (StateProvinces.CountryID = @CountryID) AND EXISTS (" + " SELECT * FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID" + " WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1)" + " AND (Cities.StateProvinceID = StateProvinces.ID) " + " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) " + "ORDER BY StateProvince", SqlDbType.Int); // StateCodeInfo.Text = SqlDbType.Int. CitiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTCitiesFROMCitiesWHERECitiesStateProvinceID), SqlDbType.Int); const string STR_SELECTPropertiesInfo = "SELECT Properties.Name2 as PropertyName2, Properties.Name, Properties.NumBedrooms, Properties.NumBaths, Properties.NumSleeps, Properties.NumTVs, Properties.NumVCRs, Properties.CityID, Properties.NumCDPlayers, Properties.ID, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Beach Front')) THEN 'Beach Front' ELSE '' END AS BeachFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Seaside')) THEN 'Seaside' ELSE '' END AS Seaside, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Lake Front')) THEN 'Lake Front' ELSE '' END AS LakeFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'River Front')) THEN 'River Front' ELSE '' END AS RiverFront, CASE WHEN EXISTS (SELECT * FROM PropertiesAmenities INNER JOIN Amenities ON PropertiesAmenities.AmenityID = Amenities.ID WHERE (PropertiesAmenities.PropertyID = Properties.ID) AND (Amenities.Amenity = 'Ski In Ski Out')) THEN 'Ski In Ski Out' ELSE '' END AS Ski, Cities.City, StateProvinces.StateProvince, Countries.Country, Regions.Region, MinimumNightlyRentalTypes.Name AS MinimumNightlyRental, PropertyTypes.Name AS Type FROM Properties INNER JOIN Cities ON Properties.CityID = Cities.ID INNER JOIN StateProvinces ON StateProvinces.ID = Cities.StateProvinceID INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID INNER JOIN Regions ON Countries.RegionID = Regions.ID INNER JOIN Users ON Properties.UserID = Users.ID LEFT OUTER JOIN MinimumNightlyRentalTypes ON Properties.MinimumNightlyRentalID = MinimumNightlyRentalTypes.ID LEFT OUTER JOIN PropertyTypes ON Properties.TypeID = PropertyTypes.ID WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (StateProvinces.CountryID = @CountryID) AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) ORDER BY StateProvinces.StateProvince, Cities.City, Type, CASE WHEN EXISTS (SELECT * FROM Invoices WHERE (PropertyID = Properties.ID) AND (PaymentAmount >= InvoiceAmount) AND (GETDATE() <= Invoices.RenewalDate)) THEN 1 ELSE 0 END DESC, Properties.ID"; PropertiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTPropertiesInfo), SqlDbType.Int); AmenitiesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT Amenities.ID, Amenity," + " PropertiesAmenities.PropertyID " + "FROM Amenities INNER JOIN PropertiesAmenities ON Amenities.ID = PropertiesAmenities.AmenityID" + " INNER JOIN Properties ON PropertiesAmenities.PropertyID = Properties.ID " + " INNER JOIN Cities ON Properties.CityID = Cities.ID INNER JOIN StateProvinces ON StateProvinces.ID = Cities.StateProvinceID " + "WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND (StateProvinces.CountryID = @CountryID)" + " AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID) AND (Amenities.Amenity NOT IN" + " ('Lake Front', 'Beach Front', 'River Front', 'Seaside', 'Ski In Ski Out', 'TV', 'VCR', 'CD Player'))", SqlDbType.Int); LocationAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT StateProvinces.ID AS StateProvinceID," + " StateProvinces.StateProvince, Countries.ID AS CountryID, Countries.Country, Regions.ID AS RegionID," + " Regions.Region, Countries.titleoverride, stateprovinces.descriptionoverride " + "FROM StateProvinces INNER JOIN Countries ON StateProvinces.CountryID = Countries.ID" + " INNER JOIN Regions ON Countries.RegionID = Regions.ID WHERE (Countries.ID = @CountryId)", SqlDbType.Int); PropertyTypesAdapter = CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), "SELECT PropertyTypes.Name,COUNT(*) as Count, PropertyTypes.ID " + " FROM Cities INNER JOIN " + " Properties ON Cities.ID = Properties.CityID " + " INNER JOIN " + " PropertyTypes ON Properties.TypeID = PropertyTypes.ID INNER JOIN " + " StateProvinces ON Cities.StateProvinceID = StateProvinces.ID INNER JOIN " + " Countries ON StateProvinces.CountryID = Countries.ID WHERE (Countries.ID = @CountryId) " + "group by PropertyTypes.Name,PropertyTypes.ID", SqlDbType.Int); if ((Request.Params["CountryID"] != null) && (Request.Params["CountryID"].Length > 0)) { try { countryid = Convert.ToInt32(Request.Params["CountryID"]); } catch (Exception) { } } if (countryid == -1) { Response.Redirect(CommonFunctions.PrepareURL("InternalError.aspx")); } // Map Display Of Country Page SqlConnection con = CommonFunctions.GetConnection(); CountryMapAdapter = new SqlDataAdapter(STR_SELECTCitiesFROMCitiesWHERECitiesStateProvinceIDNew, con);//CommonFunctions.PrepareAdapter(CommonFunctions.GetConnection(), String.Format(STR_SELECTCitiesFROMCitiesWHERECitiesStateProvinceID), SqlDbType.Int); CountryMapAdapter.SelectCommand.Parameters.Add("@CountryID", SqlDbType.Int); CountryMapAdapter.SelectCommand.Parameters["@CountryID"].Value = Convert.ToInt32(countryid); DataTable dtmap = new DataTable(); CountryMapAdapter.Fill(dtmap); List <Locationss> eList = new List <Locationss>(); foreach (DataRow dr in dtmap.Rows) { try { Locationss e1 = new Locationss(); e1.title = dr["City"].ToString(); e1.lat = Convert.ToDouble(dr["Latitude"]); e1.lng = Convert.ToDouble(dr["Longitude"]); e1.description = dr["City"].ToString(); string temp = CommonFunctions.GetSiteAddress() + "/" + dr["Country"].ToString().ToLower().Replace(" ", "_") + "/" + dr["StateProvince"].ToString().ToLower().Replace(" ", "_") + "/" + dr["City"].ToString().ToLower().Replace(" ", "_") + "/default.aspx"; e1.URL = temp; eList.Add(e1); } catch { } } string ans = JsonConvert.SerializeObject(eList, Formatting.Indented); ClientScriptManager cs = Page.ClientScript; cs.RegisterStartupScript(Page.GetType(), "JSON", "initialize(" + ans + ");", true); CitiesAdapter.SelectCommand.Parameters["@CountryId"].Value = countryid; LocationAdapter.SelectCommand.Parameters["@CountryId"].Value = countryid; PropertiesAdapter.SelectCommand.Parameters["@CountryId"].Value = countryid; AmenitiesAdapter.SelectCommand.Parameters["@CountryId"].Value = countryid; PropertyTypesAdapter.SelectCommand.Parameters["@CountryId"].Value = countryid; Session["CountryID"] = countryid; if (LocationAdapter.Fill(MainDataSet, "Location") > 0) { regionid = (int)MainDataSet.Tables["Location"].Rows[0]["RegionID"]; countryid = (int)MainDataSet.Tables["Location"].Rows[0]["CountryID"]; region = (string)MainDataSet.Tables["Location"].Rows[0]["Region"]; country = (string)MainDataSet.Tables["Location"].Rows[0]["Country"]; stateprovince = (string)MainDataSet.Tables["Location"].Rows[0]["StateProvince"]; } else { Response.Redirect(CommonFunctions.PrepareURL("InternalError.aspx")); } StateProvincesAdapter.SelectCommand.Parameters["@CountryID"].Value = countryid; RegionCountriesAdapter.SelectCommand.Parameters["@RegionId"].Value = regionid; CitiesAdapter.Fill(MainDataSet, "Cities"); PropertiesAdapter.Fill(MainDataSet, "Properties"); AmenitiesAdapter.Fill(MainDataSet, "Amenities"); StateProvincesAdapter.Fill(MainDataSet, "StateProvinces"); PropertyTypesAdapter.Fill(MainDataSet, "PropertyTypes"); RegionCountriesAdapter.Fill(MainDataSet, "CountriesRegion"); DBConnection objTemp = new DBConnection(); DataTable dtTemp = new DataTable(); try { dtTemp = VADBCommander.CountyNamesWithProperties(Request.Params["StateProvinceID"].ToString()); DataTable dtCopy = dtTemp.Copy(); dtCopy.TableName = "dtcopy"; dtCopy.Namespace = "dtcopy"; MainDataSet.Tables.Add(dtCopy); MainDataSet.Relations.Add("CitiesProperties", MainDataSet.Tables["Cities"].Columns["ID"], MainDataSet.Tables["Properties"].Columns["CityID"]); MainDataSet.Relations.Add("PropertiesAmenities", MainDataSet.Tables["Properties"].Columns["ID"], MainDataSet.Tables["Amenities"].Columns["PropertyID"]); MainDataSet.Relations.Add("CountyCities", MainDataSet.Tables["dtcopy"].Columns["ID"], MainDataSet.Tables["Cities"].Columns["countyID"]); LocationAdapterCountry.SelectCommand.Parameters["@CountryID"].Value = countryid; } catch (Exception ex) { lblInfo22.Text += ex.Message; } finally { objTemp.CloseConnection(); } foreach (DataRow datarow in MainDataSet.Tables["Cities"].Rows) { if (datarow["City"] is string) { cities += " " + (string)datarow["City"]; } } HtmlHead head = Page.Header; DataBind(); /////// common for postback and ! postback List <string> vList = new List <string>(); DataTable dt = new DataTable(); DataFunctions obj = new DataFunctions(); DataTable dtCategories = new DataTable(); DBConnection obj1 = new DBConnection(); try { if (!IsPostBack) { dt = obj.PropertiesByCase(vList, countryid, "Country"); DataView dv = dt.DefaultView; dv.Sort = "category asc"; dt = dv.ToTable(); test123.Text = "Country " + countryid.ToString() + " Count " + dt.Rows.Count.ToString(); Session["dt"] = dt; int[] i = new int[4]; i = FindNumAmenities(dt); //dtCategories = obj.FindNumCategories(dt); dtCategories = obj.FindNumCategorieswithImage(dt); DataView dvMax = dtCategories.DefaultView; dvMax.Sort = "count desc"; DataTable dtMax = dvMax.ToTable(); int vCategoryCount = 0; string firstCategory = ""; string subCategory = ""; foreach (DataRow row in dtMax.Rows) { int index = dtMax.Rows.IndexOf(row); if (index == 0) { firstCategory = row["category"].ToString(); subCategory = dt.Rows[0]["SubCategory"].ToString(); } test123.Text = test123.Text + row["count"].ToString() + ","; string vTemp = row["category"].ToString() + " (" + row["count"].ToString() + ")"; vTemp = vTemp.Replace(" ", " "); vCategoryCount = vCategoryCount + Convert.ToInt32(row["count"].ToString()); } if (!IsPostBack) { dtlStates.DataSource = dtCategories; dtlStates.DataBind(); } //numbedrooms filter dtCategories = obj.FindNumBedrooms(dt); int vBedCount = 0; foreach (DataRow row in dtCategories.Rows) { vBedCount += Convert.ToInt32(row["count"]); } Page page = (Page)HttpContext.Current.Handler; dtlStates.Style.Add("display", "block"); filerMain.Style.Add("display", "block"); if (Request.QueryString["category"] != null) { firstCategory = Convert.ToString(Request.QueryString["category"]); } { string dispString = ""; string dispString2 = ""; if (subCategory.Contains("_")) { string[] strSplit = subCategory.Split('_'); dispString = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s"; } else { dispString = UppercaseFirst(subCategory) + "s"; } if (firstCategory.Contains("_")) { string[] strSplit = firstCategory.Split('_'); dispString2 = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s"; } else { dispString2 = UppercaseFirst(firstCategory) + "s"; } altTag = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals"; ltrH11.Text = char.ToUpper(country[0]) + country.Substring(1) + " " + char.ToUpper(firstCategory[0]) + firstCategory.Substring(1) + "s"; ltrH12.Text = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals"; //ltrH1.Text = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals And " + dispString2; page.Title = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals | Vacations Abroad"; } if (firstCategory == "bandb") { firstCategory = "B&B"; } DataTable dtCategory = dt.Clone(); foreach (DataRow dr in dt.Rows) { string vTemp = dr["Category"].ToString(); //+ " (" + dr["count"].ToString() + ")"; if (vTemp.ToLower().Replace(" ", "").Trim() == firstCategory.ToLower().Replace("_", " ").Replace(" ", "")) { subCategory = dr["SubCategory"].ToString(); dtCategory.ImportRow(dr); } } DataView dv1 = dtCategory.DefaultView; dv1.Sort = "MinNightRate desc"; dtlStates.Visible = true; if (Request.QueryString["category"] != null) { string dispString = ""; if (firstCategory.Contains("_")) { string[] strSplit = firstCategory.Split('_'); dispString = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s"; } else { dispString = UppercaseFirst(firstCategory) + "s"; } ltrH11.Text = char.ToUpper(country[0]) + country.Substring(1) + " " + char.ToUpper(firstCategory[0]) + firstCategory.Substring(1) + "s"; ltrH12.Text = char.ToUpper(country[0]) + country.Substring(1) + " " + subCategory + "s"; //ltrH1.Text = char.ToUpper(country[0]) + country.Substring(1) + " " + dispString; page.Title = char.ToUpper(country[0]) + country.Substring(1) + " " + char.ToUpper(firstCategory[0]) + firstCategory.Substring(1) + "s And " + subCategory + "s | Vacations Abroad"; altTag = subCategory + " in " + country; Label3.Text = altTag; } else { string dispString = ""; string dispString2 = ""; if (subCategory.Contains("_")) { string[] strSplit = subCategory.Split('_'); dispString = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s"; } else { dispString = UppercaseFirst(subCategory) + "s"; } if (firstCategory.Contains("_")) { string[] strSplit = firstCategory.Split('_'); dispString2 = UppercaseFirst(strSplit[0]) + " " + UppercaseFirst(strSplit[1]) + "s"; } else { dispString2 = UppercaseFirst(firstCategory) + "s"; } altTag = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals"; ltrH11.Text = char.ToUpper(country[0]) + country.Substring(1) + " Vacations "; ltrH12.Text = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals"; //ltrH1.Text = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals And " + char.ToUpper(country[0]) + country.Substring(1) + " " + dispString2; page.Title = char.ToUpper(country[0]) + country.Substring(1) + " Vacation Rentals And " + " " + dispString + " | Vacations Abroad"; } string tempcountry = CommonFunctions.GetSiteAddress() + "/" + country.ToLower().Replace(" ", "_") + "/default.aspx"; lbltText.Text = "<a href=\"" + tempcountry + "\"><span class=\"CountryInternalLink\" style=\"font-weight:normal;font-style:normal\">" + "</span></a></sp>"; HtmlMeta description = new HtmlMeta(); description.Name = "description"; description.Content = "Book Now " + char.ToUpper(country[0]) + country.Substring(1) + char.ToUpper(firstCategory[0]) + firstCategory.Substring(1) + "s And unique " + subCategory + "s"; head.Controls.Add(description); //} ViewState["firstCategory"] = firstCategory; // get the Page Text DataTable dt1 = new DataTable(); try { dt1 = VADBCommander.GetMainCountryText(countryid.ToString()); } catch (Exception ex) { lblInfo.Text = ex.Message; } if (dt1.Rows.Count > 0) { if (dt1.Rows[0]["countryText"] != null) { if (!IsPostBack) { lblCountryInfo.Text = dt1.Rows[0]["countryText"].ToString(); txtCountryText.Text = dt1.Rows[0]["countryText"].ToString().Replace("<br />", Environment.NewLine); } } if (!string.IsNullOrEmpty(Convert.ToString(dt1.Rows[0]["countryText2"]))) { if (!IsPostBack) { lblInfo2.Text = dt1.Rows[0]["countryText2"].ToString(); counrtyregions.Visible = true; txtCountryText2.Text = dt1.Rows[0]["countryText2"].ToString().Replace("<br />", Environment.NewLine); } } } } string vText = "Vacations-abroad.com is a " + stateprovince + " accommodation directory of " + stateprovince + " rentals by owner and privately owned " + stateprovince + " holiday accommodation. Our short term " + stateprovince + " rentals include luxury " + stateprovince + " holiday homes, " + stateprovince + " vacation homes and " + stateprovince + " vacation home rentals which are perfect for group or family vacation rentals in " + stateprovince + " " + country; } catch (Exception ex) { lblInfo.Text = ex.Message; } DBConnection obj3 = new DBConnection(); SqlDataReader reader = obj3.ExecuteRecordSetArtificial("SELECT Cities.* FROM Cities WHERE (Cities.StateProvinceID = " + stateprovinceid + ") " + "AND EXISTS ( SELECT * FROM Properties WHERE (Properties.IfFinished = 1) AND (Properties.IfApproved = 1) AND " + "(Properties.CityID = Cities.ID) AND NOT EXISTS (SELECT * FROM Auctions WHERE PropertyID = Properties.ID)) ORDER " + "BY City"); string states1 = ""; string regionCountry = ""; foreach (DataRow dr in MainDataSet.Tables["CountriesRegion"].Rows) { string temp = CommonFunctions.GetSiteAddress() + "/" + dr["Country"].ToString().ToLower().Replace(" ", "_") + "/default.aspx"; temp = temp.ToLower(); temp = temp.Replace(' ', '_'); if (Convert.ToString(MainDataSet.Tables["Location"].Rows[0]["Country"]) == Convert.ToString(dr["Country"])) { rtLow3.InnerHtml += "<a href=\"" + temp + "\"><span class=\"CountryInternalLink\" style=\"text-decoration:underline;\">" + dr["Country"].ToString().Replace(" ", " ") + "</span></a>, "; } else { rtLow3.InnerHtml += "<a href=\"" + temp + "\"><span class=\"CountryInternalLink\">" + dr["Country"].ToString().Replace(" ", " ") + "</span></a>, "; } //rtLow3.InnerHtml += "<span class=\"CountryInternalLink\">" + dr["Country"].ToString().Replace(" ", " ") + "</span>, "; states1 += "<a href=\"" + temp + "\"><span class=\"CountryInternalLink\" style=\"font-weight:normal;font-style:normal\">" + dr["Country"].ToString().Replace(" ", " ") + "</span></a>, "; regionCountry = dr["Region"].ToString(); } states1 = ""; foreach (DataRow dr in MainDataSet.Tables["StateProvinces"].Rows) { string temp = CommonFunctions.GetSiteAddress() + "/" + country.ToLower().Replace(" ", "_") + "/" + dr["StateProvince"].ToString().ToLower().Replace(" ", "_") + "/default.aspx"; states1 += "<a href=\"" + temp + "\"><span class=\"CountryInternalLink\" style=\"font-weight:normal;font-style:normal\">" + dr["StateProvince"].ToString().Replace(" ", " ") + "</span></a>, "; } rtLow3.InnerHtml = rtLow3.InnerHtml.Remove(rtLow3.InnerHtml.Length - 2, 2); rtHd3.InnerHtml = regionCountry + ":"; //add counties to right column //add counties within state string query = ""; dt = obj1.spGetRightSideCounties(stateprovinceid); if (dt.Rows.Count > 0) { rtCountiesHd.InnerHtml = stateprovince + " Counties"; foreach (DataRow datarow in dt.Rows) { if (datarow["county"] is string) { string temp = CommonFunctions.GetSiteAddress() + "/" + stateprovince + "/Holiday-Rentals/" + datarow["county"].ToString() + "-Vacation_Rentals/default.aspx"; temp = temp.ToLower(); temp = temp.Replace(' ', '_'); divCitiesRt.InnerHtml += "<a href=\"" + temp + "\"><span class=\"CountryInternalLink\">" + datarow["county"].ToString().Replace(" ", " ") + "</span></a>, "; } } divCitiesRt.InnerHtml = divCitiesRt.InnerHtml.Remove(divCitiesRt.InnerHtml.Length - 2, 2); } else { rtCountyOut.Visible = false; lblBr.Text = ""; lblBr.Visible = false; } //add counties within state DataTable dtCountries = obj1.spStateProvByCountries(countryid); rtLowerHd.InnerHtml = country + " States"; foreach (DataRow row in dtCountries.Rows) { if (row["stateprovince"] is string) { string temp = CommonFunctions.GetSiteAddress() + "/" + country + "/" + row["stateprovince"].ToString() + "/default.aspx"; temp = temp.ToLower(); temp = temp.Replace(' ', '_'); rtLower.InnerHtml += "<a href=\"" + temp + "\">" + row["stateprovince"].ToString().Replace(" ", " ") + "</a>, "; } } rtLower.InnerHtml = rtLower.InnerHtml.Remove(rtLower.InnerHtml.Length - 2, 2); /////// common for postback and ! postback //////// string tempstate = CommonFunctions.GetSiteAddress() + "/" + country.ToLower().Replace(" ", "_") + "/default.aspx"; Session["tempstate"] = stateprovince; Session["tempcountry"] = country; lbltText.Text = lbltText.Text + states1; Page.Header.Controls.Add(new LiteralControl("<link href='/css/StyleSheetBig4.css?6=4' rel='stylesheet' type='text/css'></script>")); //HtmlMeta description = new HtmlMeta(); //description.Name = "description"; //description.Content = Description.Text.Replace("%country%", country).Replace("%stateprovince%", stateprovince). // Replace("%cities%", cities); //// Description OVER RIDE area //string DescripReplacement = MainDataSet.Tables["Location"].Rows[0]["descriptionoverride"].ToString(); //if (DescripReplacement.Length > 0) // description.Content = DescripReplacement; Page page1 = (Page)HttpContext.Current.Handler; //description.Content = page1.Title; //head.Controls.Add(description); HtmlMeta keywords = new HtmlMeta(); keywords.Name = "keywords"; keywords.Content = Keywords.Text.Replace("%country%", country).Replace("%stateprovince%", stateprovince). Replace("%cities%", cities); keywords.Content = page1.Title; head.Controls.Add(keywords); ((System.Web.UI.WebControls.Image)Master.FindControl("Logo")).AlternateText = page1.Title; }
/// <summary> /// 检查数据的合理性 /// </summary> private bool CheckData() { if (gridViewBom.DataRowCount == 0) { MessageHandler.ShowMessageBox("当前显示的数据行数为0,无法检查更新数据库。"); return(false); } for (int i = 0; i < gridViewBom.DataRowCount; i++) { for (int j = 0; j < gridViewBom.Columns.Count; j++) { bool isLookup = false; string columnStr = gridViewBom.Columns[j].FieldName; #region 检测数据是否为空 switch (columnStr) { case "Qty": //数值类型 if (DataTypeConvert.GetString(gridViewBom.GetDataRow(i)[columnStr]) == "" || DataTypeConvert.GetDouble(gridViewBom.GetDataRow(i)[columnStr]) == 0) { MessageHandler.ShowMessageBox("数值字段为空或者0,请填写后再进行检查。"); gridCrlBom.Focus(); gridViewBom.FocusedRowHandle = i; gridViewBom.FocusedColumn = gridViewBom.Columns[j]; return(false); } break; case "MotherCodeFileName": //选项类型 case "SubCodeFileName": if (DataTypeConvert.GetString(gridViewBom.GetDataRow(i)[columnStr]) == "") { MessageHandler.ShowMessageBox("选项字段为空,请填写后再进行检查。"); gridCrlBom.Focus(); gridViewBom.FocusedRowHandle = i; gridViewBom.FocusedColumn = gridViewBom.Columns[j]; return(false); } isLookup = true; break; } #endregion #region 检测选项是否是正常选项 if (isLookup) { string lookupValue = DataTypeConvert.GetString(gridViewBom.GetDataRow(i)[columnStr]); if ((((DataTable)repSearchCodeFileName.DataSource).Select(string.Format("CodeFileName='{0}'", lookupValue))).Length <= 0) { MessageHandler.ShowMessageBox("选项是非正常选项,请重新选择后再进行检查。"); gridCrlBom.Focus(); gridViewBom.FocusedRowHandle = i; gridViewBom.FocusedColumn = gridViewBom.Columns[j]; return(false); } } #endregion } } #region 检测Bom信息是否存在 DataView dv = new DataView(dSBom.Tables[0]); DataTable rootTable = dv.ToTable(true, "MotherCodeFileName"); foreach (DataRow dr in rootTable.Rows) { string mCodeFileNameStr = DataTypeConvert.GetString(dr["MotherCodeFileName"]); if (bomDAO.QueryBom_CodeFileNameCount(mCodeFileNameStr) > 0) { MessageHandler.ShowMessageBox(string.Format("Bom信息[{0}]在数据库中已经存在,不可以重复添加。", mCodeFileNameStr)); comboBoxMother.Text = mCodeFileNameStr; comboBoxMother.Focus(); return(false); } } #endregion #region 检测母物料的记录中是否有重复的子物料信息 for (int i = 0; i < gridViewBom.DataRowCount; i++) { string mCodeFileNameStr = DataTypeConvert.GetString(gridViewBom.GetDataRow(i)["MotherCodeFileName"]); string subCodeFileNameStr = DataTypeConvert.GetString(gridViewBom.GetDataRow(i)["SubCodeFileName"]); DataRow[] drs = dSBom.Tables[0].Select(string.Format("MotherCodeFileName='{0}' and SubCodeFileName='{1}'", mCodeFileNameStr, subCodeFileNameStr)); if (drs.Length > 1) { MessageHandler.ShowMessageBox(string.Format("母物料编号[{0}]中得子物料编号[{1}]有重复记录,不可以更新数据库。", mCodeFileNameStr, subCodeFileNameStr)); gridCrlBom.Focus(); gridViewBom.FocusedRowHandle = i; return(false); } } #endregion return(true); }
protected void FillPatientGrid() { UserView userView = UserView.GetInstance(); lblHeading.Text = !userView.IsAgedCareView ? "Patients" : "Residents"; int regRefID = IsValidFormRef() ? GetFormRef(false) : -1; int orgID = IsValidFormOrg() ? GetFormOrg(false) : 0; string orgIDs = orgID != 0 ? orgID.ToString() : (IsValidFormOrgs() ? GetFormOrgs(false) : string.Empty); DataTable dt = null; if (regRefID != -1) { dt = PatientReferrerDB.GetDataTable_PatientsOf(regRefID, false, false, userView.IsClinicView, userView.IsGPView, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked); } else if (orgIDs != string.Empty) { dt = RegisterPatientDB.GetDataTable_PatientsOf(false, orgIDs, false, false, userView.IsClinicView, userView.IsGPView, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked); } else { dt = PatientDB.GetDataTable(false, false, userView.IsClinicView, userView.IsGPView, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked); } // update AjaxLivePatientSurnameSearch and PatientListV2.aspx and PatientListPopup to disallow providers to see other patients. if (userView.IsProviderView) // remove any patients who they haven't had bookings with before { Patient[] patients = BookingDB.GetPatientsOfBookingsWithProviderAtOrg(Convert.ToInt32(Session["StaffID"]), Convert.ToInt32(Session["OrgID"])); System.Collections.Hashtable hash = new System.Collections.Hashtable(); foreach (Patient p in patients) { hash[p.PatientID] = 1; } for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (hash[Convert.ToInt32(dt.Rows[i]["patient_id"])] == null) { dt.Rows.RemoveAt(i); } } } Session["patientinfo_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["patientinfo_sortexpression"] != null && Session["patientinfo_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["patientinfo_sortexpression"].ToString(); GrdPatient.DataSource = dataView; } else { GrdPatient.DataSource = dt; } try { GrdPatient.DataBind(); GrdPatient.PagerSettings.FirstPageText = "1"; GrdPatient.PagerSettings.LastPageText = GrdPatient.PageCount.ToString(); GrdPatient.DataBind(); } catch (Exception ex) { this.lblErrorMessage.Visible = true; this.lblErrorMessage.Text = ex.ToString(); } } else { dt.Rows.Add(dt.NewRow()); GrdPatient.DataSource = dt; GrdPatient.DataBind(); int TotalColumns = GrdPatient.Rows[0].Cells.Count; GrdPatient.Rows[0].Cells.Clear(); GrdPatient.Rows[0].Cells.Add(new TableCell()); GrdPatient.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdPatient.Rows[0].Cells[0].Text = "No Record Found"; } }
private void btnRefresh_Click(object sender, EventArgs e) { if (TimKiem_BaoCao.CheckTuNgayDenNgay(calTuNgay.Value, calDenNgay.Value)) { DateTime dateGioDauCa; // lay gio cua ca DataTable dt = ThongTinCauHinh.GetThongTinCa(1); try { dateGioDauCa = Convert.ToDateTime(dt.Rows[0]["DauCa1"].ToString()); } catch (Exception) { dateGioDauCa = new DateTime(1900, 1, 1, 6, 0, 0); } DateTime TuNgay = new DateTime(calTuNgay.Value.Year, calTuNgay.Value.Month, calTuNgay.Value.Day, dateGioDauCa.Hour, dateGioDauCa.Minute, dateGioDauCa.Second); DateTime DenNgay = calDenNgay.Value; DenNgay = DenNgay.AddDays(1).Add(TuNgay.TimeOfDay.Add(new TimeSpan(0, 0, -1))); lblTuNgayDen.Text = string.Format("({0:HH:mm dd/MM} - {1:HH:mm dd/MM})", TuNgay, DenNgay); //Load du lieu DataTable dtDHTheoNgay = new TimKiem_BaoCao().GROUP_BaoCaoKetQuaDieuHanh_TheoCa(TuNgay, DenNgay); //Khai bao doi tuong tong object objSum; float TyTrong; for (int i = 0; i < dtDHTheoNgay.Rows.Count; i++) { if (i != 0) { string ngayInGroup = dtDHTheoNgay.Rows[i - 1]["NgayHienThi"].ToString(); string Ca = dtDHTheoNgay.Rows[i - 1]["Ca"].ToString(); if ((dtDHTheoNgay.Rows[i]["Ca"].ToString() != Ca && dtDHTheoNgay.Rows[i]["NgayHienThi"].ToString() == ngayInGroup) || (dtDHTheoNgay.Rows[i]["Ca"].ToString() != Ca && dtDHTheoNgay.Rows[i]["NgayHienThi"].ToString() != ngayInGroup) || i == (dtDHTheoNgay.Rows.Count - 1)) { objSum = dtDHTheoNgay.Compute("Sum(TongGoiTaxi)", "Ca = " + "'" + Ca + "'" + " and NgayHienThi= " + "'" + ngayInGroup + "'"); foreach (DataRow dr in dtDHTheoNgay.Rows) { if (dr["Ca"].ToString() == Ca && dr["NgayHienThi"].ToString() == ngayInGroup) { TyTrong = (float.Parse(dr["TongGoiTaxi"].ToString()) / float.Parse(objSum.ToString())) * 100; dr["TyTrong"] = TyTrong; } } } } } string sVung = StringTools.TrimSpace(txtVung.Text); // khi co dữ liệu thì bật expand/coll if (dtDHTheoNgay != null && dtDHTheoNgay.Rows.Count > 0) { chkTongNgay.Enabled = true; } if (sVung.Length > 0) { DataView dw = new DataView(dtDHTheoNgay, "Vung=" + sVung, "", DataViewRowState.ModifiedCurrent); grdDieuHanhTheoCa.DataMember = "KetQuaDieuHanh"; grdDieuHanhTheoCa.SetDataBinding(dw, "KetQuaDieuHanh"); gridExport.DataMember = "KetQuaDieuHanh"; gridExport.SetDataBinding(dw, "KetQuaDieuHanh"); } else { grdDieuHanhTheoCa.DataMember = "KetQuaDieuHanh"; grdDieuHanhTheoCa.SetDataBinding(dtDHTheoNgay, "KetQuaDieuHanh"); gridExport.DataMember = "KetQuaDieuHanh"; gridExport.SetDataBinding(dtDHTheoNgay, "KetQuaDieuHanh"); } btnExportExcel.Enabled = true; } else { MessageBox.Show(this, "Bạn phải nhập [Từ ngày] nhỏ hơn hoặc bằng [Đến ngày].", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
/// <summary> /// 绑定数据 /// </summary> public void bind() { if (!Common.Validate.IsDateTime(tboxTimeB.Text) || !Common.Validate.IsDateTime(tboxTimeE.Text)) { Common.MsgBox.Show(this, App_GlobalResources.Language.Tip_TimeError); return; } LabelArea.Text = DropDownListArea1.SelectedItem.Text; if (DropDownListArea2.SelectedIndex > 0) { LabelArea.Text += "|" + DropDownListArea2.SelectedItem.Text; } DateTime searchdateB = DateTime.Now; DateTime searchdateE = DateTime.Now; if (tboxTimeB.Text.Length > 0) { searchdateB = Convert.ToDateTime(tboxTimeB.Text); } if (tboxTimeE.Text.Length > 0) { searchdateE = Convert.ToDateTime(tboxTimeE.Text); } LabelTime.Text = searchdateB.ToString(SmallDateTimeFormat) + " " + App_GlobalResources.Language.LblTo + " " + searchdateE.ToString(SmallDateTimeFormat); string queryDateSql = @"select f_Date from T_ShopSale where F_ShopType=0 AND F_Date>='" + searchdateB.ToString(SmallDateTimeFormat) + "' and F_Date<='" + searchdateE.ToString(SmallDateTimeFormat) + "'"; if (DropDownListArea1.SelectedIndex > 0) { queryDateSql += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } queryDateSql += " GROUP BY F_Date order by F_Date"; queryDateDS = DBHelperDigGameDB.Query(queryDateSql); DataView queryDateView = queryDateDS.Tables[0].DefaultView; StringBuilder inSqlBuilder = new StringBuilder(); if (queryDateView != null && queryDateView.Count > 0) { for (int i = 0; i < queryDateView.Count; i++) { if (i == queryDateView.Count - 1) { inSqlBuilder.AppendFormat("[{0}]", Convert.ToDateTime(queryDateView[i]["f_Date"]).ToString("yyyy-MM-dd")); } else { inSqlBuilder.AppendFormat("[{0}],", Convert.ToDateTime(queryDateView[i]["f_Date"]).ToString("yyyy-MM-dd")); } } string inSql = inSqlBuilder.ToString(); string sql = @"SELECT F_ItemExcelID,F_ItemChildNum," + inSql + "FROM (SELECT F_ItemExcelID,F_ItemChildNum,F_Date,SUM(F_ItemSaleNum / F_ItemChildNum) AS F_GoodsNum FROM T_ShopSaleItem with(nolock) where F_ShopType=0 AND F_Date>='" + searchdateB.ToString(SmallDateTimeFormat) + "' and F_Date<='" + searchdateE.ToString(SmallDateTimeFormat) + "' "; if (DropDownListArea1.SelectedIndex > 0) { sql += @" and F_BigZone=" + DropDownListArea1.SelectedValue.Split(',')[1] + ""; } sql += " GROUP BY F_Date,F_ItemExcelID,F_ItemChildNum) as TempData pivot (sum(F_GoodsNum) for F_Date in (" + inSql + ")) as ourpivot order by F_ItemExcelID"; try { ds = DBHelperDigGameDB.Query(sql); DataView myView = ds.Tables[0].DefaultView; if (myView.Count == 0) { lblerro.Visible = true; myView.AddNew(); } else { lblerro.Visible = false; } GridView1.DataSource = myView; GridView1.DataBind(); if (ControlChart1.Visible == true) { ControlChart1.SetChart(GridView1, LabelTitle.Text.Replace(">>", " - ") + " " + LabelArea.Text + " " + LabelTime.Text, ControlChartSelect1.State, true, 0, 0); } } catch (System.Exception ex) { GridView1.DataSource = null; GridView1.DataBind(); lblerro.Visible = true; lblerro.Text = App_GlobalResources.Language.LblError + ex.Message; } } else { lblerro.Visible = true; GridView1.DataSource = null; } }
protected void btnexcel3510_Click(object sender, EventArgs e) { if (fuexcel.FileName == null && fuexcel.FileName == "") //if no file selected the give error { diverror.Visible = true; diverror.InnerHtml = "Please select Excel file."; diverror.Attributes.Add("class", "alert alert-danger"); return; } else //---------------------------------------------------if file is selected { diverror.Visible = true; diverror.InnerHtml = fuexcel.FileName; string ErrText = ""; DataTable dtExcel = new DataTable(); try { string path = Server.MapPath("~/App_Data/") + fuexcel.PostedFile.FileName; fuexcel.SaveAs(path); dtExcel = Lo.CreateExcelConnection(path, "data", out ErrText); if (ErrText.ToLower() == "success") // if sqlhelper returning NO ERROR in importing { DataView dv = new DataView(dtExcel); dv.RowFilter = "Status='A'"; dtExcel = dv.ToTable(); } else // ------------------------------if sqlhelper returning ERROR in importing { diverror.Visible = true; diverror.InnerHtml = ErrText; return; } } catch (Exception ex) { diverror.Visible = true; diverror.InnerHtml = ErrText + ex.Message; diverror.Attributes.Add("class", "alert alert-danger"); } // if excel import completed without error if (dtExcel.Rows.Count < 1) { diverror.Visible = true; diverror.InnerHtml = "No data imported from excel file !!"; diverror.Attributes.Add("class", "alert alert-danger"); return; } else { try { var rowsCount = Convert.ToInt32(dtExcel.Rows.Count); lblRowCount.Text = "Rows Processed:- " + rowsCount; DataTable dtPid = Lo.RetrivePid((txtL1.Text), (txtL2.Text)); if (dtPid.Rows.Count < 1) { diverror.Visible = true; diverror.InnerHtml = "No PID exist !!"; diverror.Attributes.Add("class", "alert alert-danger"); return; } str = Lo.SaveExcel3510(dtExcel, (txtL1.Text), (txtL2.Text), (dtPid.Rows[0][0].ToString())); if (str == "Save") { diverror.Visible = true; diverror.InnerHtml = "Data imported successfully from excel file !!\n\nTotal Rows - " + dtExcel.Rows.Count.ToString() + "."; diverror.Attributes.Add("class", "alert alert-success"); dtExcel.Dispose(); dtExcel = null; } else { diverror.Visible = true; diverror.InnerHtml = "User Error: Error in excel data. Technical Error: " + str + ""; diverror.Attributes.Add("class", "alert alert-danger"); } } catch (Exception ex) { diverror.Visible = true; diverror.InnerHtml = "User Error: Error in excel data. Technical Error: " + ex.Message + ""; diverror.Attributes.Add("class", "alert alert-danger"); } } } }