当前位置: 首页>>代码示例>>C#>>正文


C# DataColumn.SetOrdinal方法代码示例

本文整理汇总了C#中System.Data.DataColumn.SetOrdinal方法的典型用法代码示例。如果您正苦于以下问题:C# DataColumn.SetOrdinal方法的具体用法?C# DataColumn.SetOrdinal怎么用?C# DataColumn.SetOrdinal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.DataColumn的用法示例。


在下文中一共展示了DataColumn.SetOrdinal方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: lBtnToExcel_Click

 //导出数据到Excel
 protected void lBtnToExcel_Click(object sender, EventArgs e)
 {
     //获取数据并填充到数据表
     using (var da = new t_eng_lot_cardTableAdapter())
     {
         //查询条件
         string strWhere = GetWhereContent();
         //获取前1万行数据
         var tab = da.GetPagedData(0, 10000, strWhere, "order by [id] desc");
         //tab.Columns.Add("film_is_new", typeof(string), "case when [film]='true' then '新' when [film]='false' then '旧' else '' end");
         var col = new DataColumn("film_is_new", typeof(string));
         tab.Columns.Add(col);
         col.SetOrdinal(4);
         int len = tab.Rows.Count;
         for (int i = 0; i < len; i++)
         {
             var row = tab.Rows[i];
             var film = row["film"];
             if (film != DBNull.Value)
             {
                 bool isNew = Convert.ToBoolean(film);
                 row["film_is_new"] = isNew ? "新" : "旧";
             }
         }
         tab.Columns.Remove("film");
         //设置列标题
         string[] titleCol =
             (@"序号,客户,客户编号,生产编号,菲林,菲林日期,
             PNL含PCS数,开料PNL数,大料总单只数,样板开料SET数,样板开料PCS数,
             A板PNL长,A板PNL宽,A板大料PNL数,A板大料SET数,A板大料PCS数,
             B板PNL长,B板PNL宽,B板大料PNL数,B板大料SET数,
             B板大料PCS数,材料,模冲号,备注,
             次序1,指示1,
             次序2,指示2,
             次序3,指示3,
             次序4,指示4,
             次序5,指示5,
             次序6,指示6,
             次序7,指示7,
             次序8,指示8,
             次序9,指示9,
             次序10,指示10,
             次序11,指示11,
             次序12,指示12,
             次序13,指示13,
             次序14,指示14,
             次序15,指示15,
             次序16,指示16,
             次序17,指示17,
             次序18,指示18,
             次序19,指示19,
             次序20,指示20,
             次序21,指示21,
             次序22,指示22,
             次序23,指示23,
             次序24,指示24,
             次序25,指示25,
             次序26,指示26,
             次序27,指示27,
             次序28,指示28,
             次序29,指示29,
             次序30,指示30,
             次序31,指示31,
             次序32,指示32,
             次序33,指示33,
             次序34,指示34,
             次序35,指示35,
             次序36,指示36,
             次序37,指示37,
             次序38,指示38,
             次序39,指示39,
             次序40,指示40,
             次序41,指示41,
             次序42,指示42,
             次序43,指示43,
             次序44,指示44,
             次序45,指示45,
             次序46,指示46,
             次序47,指示47,
             次序48,指示48,
             次序49,指示49,
             次序50,指示50,
             V-CUT备注,
             菲林尺寸,成品尺寸,单元面积,利用率,
             物料编码,开料图,编制,编制时间,
             审核,审核时间,修改时间").Split(',');
         //设置表名称
         string titleTab = "工程MI资料清单";
         //临时文件名称
         string fileName = titleTab + DateTime.Now.ToString("yyMMddHHmmss") + ".xls";
         //执行导出数据到excel
         bool isSuccess = ydPublicMethod.DataTable2Excel(tab, titleCol, ref fileName, titleTab);
         //如果成功则跳转到指定页面
         if (isSuccess)
         {
             Response.Redirect(fileName);
             //停止加载后续内容
             Response.End();
         }
//.........这里部分代码省略.........
开发者ID:yangdan8,项目名称:ydERPTY,代码行数:101,代码来源:LotCard.aspx.cs

示例2: SetOrdinalTest

        	public void SetOrdinalTest()
		{
			DataColumn col = new DataColumn("col", typeof(int));
			try {
				col.SetOrdinal(2);
				Assert.Fail ("#1");
			} catch (ArgumentException e) { }

			DataTable table = new DataTable();
			DataColumn col1 = table.Columns.Add ("col1", typeof (int));
			DataColumn col2 = table.Columns.Add("col2", typeof(int));
			DataColumn col3 = table.Columns.Add("col3", typeof(int));

			Assert.AreEqual("col1", table.Columns[0].ColumnName, "#2");
			Assert.AreEqual("col3", table.Columns[2].ColumnName, "#3");

			table.Columns[0].SetOrdinal (2);
			Assert.AreEqual("col2", table.Columns[0].ColumnName, "#4");
			Assert.AreEqual("col1", table.Columns[2].ColumnName, "#5");

			Assert.AreEqual(0, col2.Ordinal, "#6");
			Assert.AreEqual(1, col3.Ordinal, "#7");
			Assert.AreEqual(2, col1.Ordinal, "#8");

			try {
				table.Columns[0].SetOrdinal (-1);
				Assert.Fail ("#9");
			} catch (ArgumentOutOfRangeException e) { }

			try {
				table.Columns[0].SetOrdinal (4);
				Assert.Fail ("#10");
			} catch (ArgumentOutOfRangeException e) { }
		}
开发者ID:wamiq,项目名称:debian-mono,代码行数:34,代码来源:DataColumnTest2.cs

示例3: btnImportAndRefresh_Click

        private void btnImportAndRefresh_Click(object sender, EventArgs e)
        {
            if (DtSource.Rows != null && DtSource.Rows.Count > 0)
            {
                FmProgressBar progressBar = new FmProgressBar("数据导入中........");
                var tempTable = DtSource.Copy();
                string runMsg = string.Empty;
                bool bSuccess = true;
                Task task = new Task(() =>
                {
                    try
                    {
                        DataColumn dtRecorderColumn = new DataColumn("Recorder", typeof(string));
                        DataColumn dtShopIdColumn = new DataColumn("ShopId", typeof(Int32));
                        tempTable.Columns.Add(dtShopIdColumn);
                        tempTable.Columns.Add(dtRecorderColumn);
                        dtShopIdColumn.SetOrdinal(0);
                        dtRecorderColumn.SetOrdinal(1);
                        int defaultPhone = 1;
                        foreach (DataRow datarow in tempTable.Rows)
                        {
                            datarow[dtShopIdColumn] = GlobalCaches.Instance.CurUser.ShopId;
                            datarow[dtRecorderColumn] = GlobalCaches.Instance.CurUser.RealName;

                            if (string.IsNullOrEmpty(datarow["客户电话"].ToString().Trim()))
                            {
                                datarow["客户电话"] = defaultPhone++;
                            }

                            string toShopNumDesc = datarow["几次来店"].ToString().Trim();
                            datarow["几次来店"] = toShopNumDesc == "首次" ? 1 : (toShopNumDesc == "二次" ? 2 : 3);

                            DateTime rowDate = Convert.ToDateTime(datarow["日期"]);
                            if (!dateList.Contains(rowDate))
                                dateList.Add(rowDate);

                        }
                        FrontRecordBusiness.Instance.BulkInsertData(tempTable);
                        runMsg = "导入成功";
                        bSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        bSuccess = false;
                        runMsg = string.Format("导入失败:{0}", ex.ToString());
                    }
                    finally
                    {
                        tempTable.Dispose();
                        this.BeginInvoke(new MethodInvoker(delegate()
                        {
                            progressBar.LoadCaption = runMsg;
                            progressBar.DialogResult = DialogResult.OK;
                            this.DialogResult = DialogResult.Cancel;
                            //XtraMessageBox.Show(runMsg, "提示", MessageBoxButtons.OK);
                            if (bSuccess && RefreshTable != null)
                                RefreshTable(this, EventArgs.Empty);
                        }));
                    }
                });

                task.Start();

                progressBar.ShowDialog();
            }
        }
开发者ID:zjk537,项目名称:CRM_4S,代码行数:66,代码来源:FmFrontImport.cs

示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {   //load the event detail 
        if (Session["EventNumber"] == null) return;
        eventNum = (Session["EventNUmber"]).ToString();

        if (Session["gridTable"] == null) return;
        DataTable dt = (DataTable)HttpContext.Current.Session["gridTable"];


        // load the event detail to show
        #region   
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i]["EventNumber"].ToString() == eventNum)
            {
                latHF.Value = dt.Rows[i]["Lat"].ToString();
                lngHF.Value = dt.Rows[i]["Lng"].ToString();
                ANS_MaxPlayerLbl.Text = dt.Rows[i]["NumOfParticipants"].ToString();
                iconImg.ImageUrl = dt.Rows[i]["ImageUrl"].ToString();
                ANS_datatimelbl.Text = dt.Rows[i]["Time"].ToString();
                ANS_locationLbl.Text = dt.Rows[i]["Address"].ToString();
                ANS_commentLbl.Text = dt.Rows[i]["Comments"].ToString();
                ANS_Frequency.Text = dt.Rows[i]["Frequncy"].ToString();
                ANS_AgeLbl.Text = dt.Rows[i]["MinAge"].ToString() + "-" + dt.Rows[i]["MaxAge"].ToString();
                EventNameLbl.Text = dt.Rows[i]["Description"].ToString();
                User u = new User();
                u.UserId = int.Parse(dt.Rows[i]["AdminId"].ToString());
                DataTable dtName = u.CheckUserName();
                ANS_AdminLbl.Text = dtName.Rows[0]["Fname"].ToString() + " " + dtName.Rows[0]["Lname"].ToString();
                bool ansTemp = (bool)dt.Rows[0]["Private"];
                string temp = "Public";
                if (ansTemp)
                    temp = "Private";
                ANS_EventTypelbl.Text = temp;
            }
        }
        #endregion 

        //loag the users that register to this event
        #region
      
        EventOnAir EV = new EventOnAir();
        DataTable dtUser = EV.ReadUserInEvent(eventNum);

        //adding the num coulm
        DataColumn dc = new DataColumn("num");
        dc.DataType = typeof(int);
        dtUser.Columns.Add(dc);
        dc.SetOrdinal(0);

        for (int i = 0; i < int.Parse(ANS_MaxPlayerLbl.Text); i++)
         {
             DataRow NewRow = dtUser.NewRow();
             dtUser.Rows.Add(NewRow); 
        }

        playerTableGrv.DataSource = dtUser;
        playerTableGrv.DataBind();
        playerTableGrv.HeaderRow.Cells[0].Text = "";
       
        //add the num of row like the num of players
        for (int i = 0; i < playerTableGrv.Rows.Count; i++)
        {
            playerTableGrv.Rows[i].Cells[0].Text = (i + 1).ToString();
        }
  
    }
开发者ID:nategot,项目名称:Project,代码行数:67,代码来源:joinEvent.aspx.cs

示例5: GetTableDefinitionDt

        /// <summary>
        /// 返回表或结构的字段定义
        /// </summary>
        /// <param name="pSystemName">SAP系统</param>
        /// <param name="pTableName">表或结构名</param>
        /// <returns></returns>
        public static DataTable GetTableDefinitionDt(String pSystemName, String pTableName, String pTypeName = "")
        {
            if (string.IsNullOrEmpty(pTypeName))
            {
                pTypeName = pTableName;
            }
            try
            {
                // DataTable dt = SAPINT.Function.SAPFunction.DDIF_FIELDINFO_GET(pSystemName, pTableName);
                DataTable dt = _GetSAPTableDef(pSystemName, pTypeName);
                if (dt == null)
                {
                    throw new SAPException(String.Format("无法获取表结构{0}的定义", pTableName));
                }
                else
                {

                    DataColumn dc = new DataColumn("Selected", typeof(bool));
                    dc.DefaultValue = false;
                    dt.Columns.Add(dc);
                    dc.SetOrdinal(0);
                    _TransFormDataTypeForDt(dt);
                }
                return dt;
            }
            catch (Exception exception)
            {
                throw new SAPException(exception.Message);
            }
        }
开发者ID:SyedMdKamruzzaman,项目名称:sap_interface,代码行数:36,代码来源:RFCTableInfo.cs

示例6: DataBindingEvent

        public void DataBindingEvent(object sender, EventArgs e)
        {
            // depending on the type of WaterMarkLines ... we need to perform some operations...

            for (int i = 0; i < this.dt.Columns.Count; i++ )
                this.dt.Columns[i].SetOrdinal(i);
            this.dt.AcceptChanges();

            // keep a list of original columns...
            List<DataColumn> originalColumns = new List<DataColumn>();
            foreach (DataColumn zz in this.dt.Columns)
                originalColumns.Add(zz);

            foreach (ComboChartLineSeries ln in this.LineSeries)
                {

                    if (this.dt.Columns.Contains(ln.LineName))
                        continue;

                    switch (ln.FunctType)
                    {

                        case ComboChartLineSeries.FUNCTION_TYPE.FIXED:
                            {
                                DataColumn dc = new DataColumn(ln.LineName, typeof(decimal));
                                dc.Caption = ln.LineName;
                                this.dt.Columns.Add(dc);
                                dc.SetOrdinal(this.dt.Columns.Count - 1);

                                this.dt.AcceptChanges();

                                for (int i = 0; i < this.dt.Rows.Count; i++)
                                {
                                    dt.Rows[i].SetField<decimal>(dc, ln.FixedValue);
                                }
                                this.dt.AcceptChanges();

                                ln.Column = this.dt.Columns.Count - 2;
                                this.GviComboChartLine.Add(ln);
                                break;
                            }
                        case ComboChartLineSeries.FUNCTION_TYPE.SUM:
                            {
                                DataColumn dc = new DataColumn(ln.LineName, typeof(decimal));
                                dc.Caption = ln.LineName;
                                this.dt.Columns.Add(dc);
                                dc.SetOrdinal(this.dt.Columns.Count - 1);

                                this.dt.AcceptChanges();

                                for (int i = 0; i < this.dt.Rows.Count; i++)
                                {
                                    DataRow dr = dt.Rows[i];
                                    decimal val = 0;
                                    foreach (DataColumn cc in originalColumns.Where(c => c.DataType.IsNumeric()))
                                    {
                                        val += decimal.Parse(dr[cc].ToString());
                                    }
                                    dt.Rows[i].SetField<decimal>(dc, val);
                                }
                                this.dt.AcceptChanges();

                                ln.Column = this.dt.Columns.Count - 2;
                                this.GviComboChartLine.Add(ln);
                                break;
                            }
                        case ComboChartLineSeries.FUNCTION_TYPE.AVG:
                            {
                                DataColumn dc = new DataColumn(ln.LineName, typeof(decimal));
                                dc.Caption = ln.LineName;
                                this.dt.Columns.Add(dc);
                                dc.SetOrdinal(this.dt.Columns.Count - 1);

                                this.dt.AcceptChanges();

                                for (int i = 0; i < this.dt.Rows.Count; i++)
                                {
                                    DataRow dr = dt.Rows[i];
                                    decimal val = 0;
                                    foreach (DataColumn cc in originalColumns.Where(c => c.DataType.IsNumeric()))
                                    {
                                        val += decimal.Parse(dr[cc].ToString());
                                    }
                                    dt.Rows[i].SetField<decimal>(dc, val / originalColumns.Where(c => c.DataType.IsNumeric()).Count());
                                }
                                this.dt.AcceptChanges();

                                ln.Column = this.dt.Columns.Count - 2;
                                this.GviComboChartLine.Add(ln);
                                break;
                            }
                        case ComboChartLineSeries.FUNCTION_TYPE.COUNT:
                            {
                                DataColumn dc = new DataColumn(ln.LineName, typeof(decimal));
                                dc.Caption = ln.LineName;
                                this.dt.Columns.Add(dc);
                                dc.SetOrdinal(this.dt.Columns.Count - 1);

                                this.dt.AcceptChanges();

//.........这里部分代码省略.........
开发者ID:JulsMan,项目名称:googlevisualizationsdotnet,代码行数:101,代码来源:GVComboChart.cs

示例7: CreateUpdateDataTable

        protected DataTable CreateUpdateDataTable(List<AdminLevelDemography> levels)
        {
            DataTable data = new System.Data.DataTable();
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("ID") + "#"));
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("Location") + "#"));
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("YearCensus")));
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("GrowthRate")));
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("TotalPopulation")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("Pop0Month")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("PopPsac")));
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("PopSac")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("Pop5yo")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("PopAdult")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("PopFemale")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("PopMale")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("PercentRural")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("Notes")));

            // Add rows to data table
            foreach (AdminLevelDemography l in levels)
            {
                DataRow row = data.NewRow();
                row["* " + TranslationLookup.GetValue("ID") + "#"] = l.Id;
                row["* " + TranslationLookup.GetValue("Location") + "#"] = l.AdminLevelId;

                List<AdminLevel> parents = demo.GetAdminLevelParentNames(l.Id);
                for (int i = 0; i < parents.Count; i++)
                {
                    if (!data.Columns.Contains("* " + parents[i].LevelName))
                    {
                        DataColumn dc = new DataColumn("* " + parents[i].LevelName);
                        data.Columns.Add(dc);
                        dc.SetOrdinal(i + 2);
                    }
                    row["* " + parents[i].LevelName] = parents[i].Name;
                }

                row["* " + TranslationLookup.GetValue("YearCensus")] = l.YearCensus;
                row["* " + TranslationLookup.GetValue("GrowthRate")] = l.GrowthRate;
                row["* " + TranslationLookup.GetValue("TotalPopulation")] = l.TotalPopulation;
                row[TranslationLookup.GetValue("Pop0Month")] = l.Pop0Month;
                row[TranslationLookup.GetValue("PopPsac")] = l.PopPsac;
                row["* " + TranslationLookup.GetValue("PopSac")] = l.PopSac;
                row[TranslationLookup.GetValue("Pop5yo")] = l.Pop5yo;
                row[TranslationLookup.GetValue("PopAdult")] = l.PopAdult;
                row[TranslationLookup.GetValue("PopFemale")] = l.PopFemale;
                row[TranslationLookup.GetValue("PopMale")] = l.PopMale;
                row[TranslationLookup.GetValue("PercentRural")] = l.PercentRural;
                row[TranslationLookup.GetValue("Notes")] = l.Notes;
                data.Rows.Add(row);
            }
            return data;
        }
开发者ID:ericjohnolson,项目名称:NadaNtd,代码行数:53,代码来源:AdminLevelImporter.cs

示例8: CreateInsertDataTable

        private DataTable CreateInsertDataTable(AdminLevelType type)
        {
            DataTable data = new System.Data.DataTable();
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("Location") + "#"));
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("YearCensus")));
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("GrowthRate")));
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("TotalPopulation")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("Pop0Month")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("PopPsac")));
            data.Columns.Add(new System.Data.DataColumn("* " + TranslationLookup.GetValue("PopSac")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("Pop5yo")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("PopAdult")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("PopFemale")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("PopMale")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("PercentRural")));
            data.Columns.Add(new System.Data.DataColumn(TranslationLookup.GetValue("Notes")));

            DemoRepository drepo = new DemoRepository();
            var allUnits = drepo.GetAdminLevelByLevel(type.LevelNumber);
            foreach (AdminLevel l in allUnits)
            {
                DataRow row = data.NewRow();
                row["* " + TranslationLookup.GetValue("Location") + "#"] = l.Id; 

                List<AdminLevel> parents = demo.GetAdminLevelParentNames(l.Id);
                for (int i = 0; i < parents.Count; i++)
                {
                    if (!data.Columns.Contains("* " + parents[i].LevelName))
                    {
                        DataColumn dc = new DataColumn("* " + parents[i].LevelName);
                        data.Columns.Add(dc);
                        dc.SetOrdinal(i + 1);
                    }
                    row["* " + parents[i].LevelName] = parents[i].Name;
                }
                
                data.Rows.Add(row);
            }
            return data;
        }
开发者ID:ericjohnolson,项目名称:NadaNtd,代码行数:40,代码来源:AdminLevelImporter.cs

示例9: Add

		/// <summary>
		/// Creates and adds the specified DataColumn object to the DataColumnCollection.
		/// </summary>
		/// <param name="column">The DataColumn to add.</param>
		public void Add(DataColumn column)
		{

			if (column == null)
				throw new ArgumentNullException ("column", "'column' argument cannot be null.");

			if (column.ColumnName.Equals(String.Empty))
			{
				column.ColumnName = GetNextDefaultColumnName ();
			}

//			if (Contains(column.ColumnName))
//				throw new DuplicateNameException("A DataColumn named '" + column.ColumnName + "' already belongs to this DataTable.");

			if (column.Table != null)
				throw new ArgumentException ("Column '" + column.ColumnName + "' already belongs to this or another DataTable.");

			CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Add, this);

			column.SetTable (parentTable);
			RegisterName(column.ColumnName, column);
			int ordinal = base.List.Add(column);
			column.SetOrdinal (ordinal);

			// if table already has rows we need to allocate space 
			// in the column data container 
			if ( parentTable.Rows.Count > 0 ) {
				column.DataContainer.Capacity = parentTable.RecordCache.CurrentCapacity;
			}

			if (column.AutoIncrement) {
				DataRowCollection rows = column.Table.Rows;
				for (int i = 0; i < rows.Count; i++)
					rows [i] [ordinal] = column.AutoIncrementValue ();
			}

			if (column.AutoIncrement)
				autoIncrement.Add(column);

			OnCollectionChanged (e);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:45,代码来源:DataColumnCollection.cs

示例10: changeColumnButton_Click

        /// <summary>
        /// Handles name change for the column in a table
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
		private void changeColumnButton_Click(object sender, System.EventArgs e)
		{
            ListViewItem listViewItem = columnsListbox.SelectedItems[0];
            if (!ValidateSelectedColumn() || 
                !ValidateColumnNameAndType(columnNameTextbox.Text, listViewItem.SubItems[1].Text))
			{
				return;
			}

			string prevColumnName = listViewItem.Text;
			listViewItem.Text = columnNameTextbox.Text;
			currentTable.Columns[prevColumnName].ColumnName = columnNameTextbox.Text;

            if (dataSet.Tables[0].Rows.Count != 0 &&
                listViewItem.SubItems[1].Text != columnTypeCombobox.Text)
            {
                if (DialogResult.OK == MessageBox.Show("Column type change will result in data from that column to be dropped. \n Do you want to go ahead?",
                    "Xml Store v1.0", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
                {
                    // can't change the data type once data exists
                    listViewItem.SubItems[1].Text = columnTypeCombobox.Text;
                    int indexOf = currentTable.Columns.IndexOf(columnNameTextbox.Text);
                    currentTable.Columns.Remove(columnNameTextbox.Text);
                    DataColumn column = new DataColumn(listViewItem.SubItems[0].Text, Type.GetType("System." + columnTypeCombobox.Text));
                    currentTable.Columns.Add(column);
                    column.SetOrdinal(indexOf);
                }
                else
                    return;
            }
		}
开发者ID:shikha577,项目名称:git.xmlstore.io,代码行数:36,代码来源:XmlStore.cs

示例11: CreateDataTable

        private DataTable CreateDataTable(IDataReader reader)
        {
            DataTable schema = reader.GetSchemaTable();

            DataTable data = new DataTable();

            foreach (DataRow row in schema.Rows)
            {
                DataColumn col = new DataColumn(Convert.ToString(row["ColumnName"]));

                data.Columns.Add(col);

                col.SetOrdinal(Convert.ToInt32(row["ColumnOrdinal"]));
            }

            while (reader.Read())
            {
                DataRow row = data.NewRow();

                foreach (DataColumn col in data.Columns)
                {
                    row.SetField(col.ColumnName, reader.GetValue(col.Ordinal));
                }

                data.Rows.Add(row);
            }

            return data;
        }
开发者ID:chrishensel,项目名称:ezNReporting,代码行数:29,代码来源:DbDataProvider.cs

示例12: getForecastOnly

    public static DataTable getForecastOnly(int startPeriod, int endPeriod, int salesman, string oemName, string plant, string group, bool subSales, bool bkSales)
    {
        DataTable dt2 = new DataTable();

        DataSet ds = getDSbyAny(startPeriod, endPeriod, salesman, oemName, plant, group, subSales, bkSales);
        if (ds.Tables[0].Rows.Count > 0 && ds.Tables[1].Rows.Count > 0)
        {
            int cp = currentPeriod();
            int pv = 0;
            //dt2 = TableVtoH2b(ds, cp);
            //dt2 = TableVtoH2a(ds, cp);
            //dt2 = TableVtoH2(ds, cp);
            dt2 = TableVtoH3(ds, cp);
            int coln = dt2.Columns.Count - 1;
            for(int x = coln;  x >0; x--)
            {
                DataColumn col = dt2.Columns[x];
                if (col.ColumnName.IndexOf("actual") >= 0)
                    dt2.Columns.Remove(col);
                if (col.ColumnName.IndexOf("gap") >= 0)
                    dt2.Columns.Remove(col);
            }
                DataTable tdCV = ds.Tables[2];
                for (int j = 0; j < tdCV.Rows.Count; j++)
                {
                    string n = (j + 1).ToString() + "_view";
                    if (tdCV.Rows.Count > j)
                        n = tdCV.Rows[j][0].ToString() + " view";
                    DataColumn colm = new DataColumn(n, typeof(double));
                    colm.DefaultValue = 0;
                    dt2.Columns.Add(colm);
                    colm.SetOrdinal(j + 3);
                }
            foreach (DataRow oem in dt2.Rows)
            {
                foreach (DataRow fcstRow in ds.Tables[1].Select("OEMID=" + oem[1].ToString()))
                {
                    pv = Convert.ToInt32(fcstRow["fiscal_period"]);
                    if (pv > 0)
                        oem[pv.ToString() + " fcst"] = fcstRow["fcst_amt"].ToString();
                }
                foreach (DataRow vRow in ds.Tables[3].Select("OEMID=" + oem[1].ToString()))
                {
                    oem[vRow["fiscal_period"] + " view"] = vRow["actual_amt"].ToString();
                }

            }
            dt2.Columns.Remove(dt2.Columns[dt2.Columns.Count - 1]);
            /*
            int lr = dt2.Rows.Count - 1;
            for (int i = 3; i < dt2.Columns.Count; i++)
            {
                string o = dt2.Compute("sum([" + dt2.Columns[i].ColumnName + "])", null).ToString();
                dt2.Rows[lr][i] = Convert.ToInt32(o); ;
            }
             */

        }
        ds.Dispose();
        return dt2;
    }
开发者ID:rivernli,项目名称:SalesForecast,代码行数:61,代码来源:Forecast.cs

示例13: QueryPlugins

        /// <summary>
        /// Method to process all Query plugins.
        /// </summary>
        private void QueryPlugins(string query, List<string> types, bool sensitive)
        {
            foreach (string tType in types) //Cycle through a List<string>
            {
                foreach (var qPlugins in this.QPlugins) //Cycle through all query plugins
                {
                    foreach (string qType in qPlugins.TypesAccepted)  //Cycle though a List<string> within the IQueryPlugin interface AcceptedTypes
                    {
                        if (qType == tType) //Match the two List<strings>, one is the AcceptedTypes and the other is the one returned from ITypeQuery
                        {
                            using (GenericParserAdapter parser = new GenericParserAdapter())
                            {
                                using (TextReader sr = new StringReader(qPlugins.Result(query, qType, sensitive)))
                                {
                                    Random rNum = new Random();

                                    parser.SetDataSource(sr);
                                    parser.ColumnDelimiter = Convert.ToChar(",");
                                    parser.FirstRowHasHeader = true;
                                    parser.MaxBufferSize = 4096;
                                    parser.MaxRows = 500;
                                    parser.TextQualifier = '\"';

                                    DataTable tempTable = parser.GetDataTable();
                                    tempTable.TableName = qPlugins.Name.ToString();
                                    if (!tempTable.Columns.Contains("Query"))
                                    {
                                        DataColumn tColumn = new DataColumn("Query");
                                        tempTable.Columns.Add(tColumn);
                                        tColumn.SetOrdinal(0);
                                    }

                                    foreach (DataRow dr in tempTable.Rows)
                                    {
                                        dr["Query"] = query;
                                    }

                                    if (!resultDS.Tables.Contains(qPlugins.Name.ToString()))
                                    {
                                        resultDS.Tables.Add(tempTable);
                                    }
                                    else
                                    {
                                        resultDS.Tables[qPlugins.Name.ToString()].Merge(tempTable);
                                    }
                                    pluginsLB.DataContext = resultDS.Tables.Cast<DataTable>().Select(t => t.TableName).ToList();
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:thelordzero,项目名称:ALeRT,代码行数:56,代码来源:MainWindow.xaml.cs


注:本文中的System.Data.DataColumn.SetOrdinal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。