• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Data.DataTable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



System.Data.DataTable类属于命名空间,在下文中一共展示了System.Data.DataTable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Insert

		public Int16 Insert(ParkingRateDetails Details)
		{
			try 
			{
                Details.CreatedByName = Details.ParkingRateID == 0 ? Details.CreatedByName : Details.LastUpdatedByName;

                Save(Details);

                string SQL = "SELECT LAST_INSERT_ID();";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID");
                base.MySqlDataAdapterFill(cmd, dt);
                

                Int16 iID = 0;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int16.Parse(dr[0].ToString());
                }

				return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
开发者ID:marioricci,项目名称:erp-luma,代码行数:32,代码来源:ParkingRates.cs


示例2: bindgrid

        public void bindgrid()
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            if (OboutDropDownList1.SelectedValue == "Clients")
            {
                dt = Functions.DB.GetCustomers();
            }
            else if (OboutDropDownList1.SelectedValue == "Sales Reps")
            {
                dt = Functions.DB.GetSalesReps();
            }

            Grid1.DataSource = dt;
            Grid1.DataBind();
            string ID = string.Empty;
            SqlDataSource src = new SqlDataSource();
            if (dt.Rows.Count > 0)
            {
                System.Collections.Hashtable al = Grid1.Rows[0].ToHashtable();
                ID = al["ID"].ToString();
            }
            if (OboutDropDownList1.SelectedValue == "Clients")
            {
                src = Functions.DB.GetSQLDataSource2("SELECT top 1 *  FROM CLIENT_DAT Where ID='" + ID + "'");
            }
            else if (OboutDropDownList1.SelectedValue == "Sales Reps")
            {
                src = Functions.DB.GetSQLDataSource("SELECT top 1 *  FROM SalesReps Where ID=" + ID);
            }

            // SuperForm1.DefaultMode = DetailsViewMode.ReadOnly;
            SuperForm1.DataSource = src;
            SuperForm1.DataBind();
        }
开发者ID:Truplaya53,项目名称:CompassNet,代码行数:35,代码来源:DataUpdate.aspx.cs


示例3: BindDemo

        private void BindDemo()
        {
            ITwitterAuthorizer autentikasi = GetInformasiKredensial();

            var TwitterDataContext = new TwitterContext(autentikasi);

            var hasilpencarian = (from search in TwitterDataContext.Search
                                  where search.Type == SearchType.Search &&
                                        search.Query == "#PERSIB" &&
                                        search.ResultType == ResultType.Recent &&
                                        search.PageSize == 100
                                  select search)
                .Single();

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("name");
            dt.Columns.Add("text");

            foreach (SearchEntry item in hasilpencarian.Results)
            {
                dt.Rows.Add(item.FromUser, item.Text);
            }

            gvMain.DataSource = dt;
            gvMain.DataBind();
        }
开发者ID:go2ismail,项目名称:JurusTwitterAPISourceCode,代码行数:26,代码来源:Default.aspx.cs


示例4: Main

        static void Main(string[] args)
        {
            MethodInfo[] ms = typeof(object).GetMethods();
            foreach (MethodInfo m in ms)
            {
                Console.WriteLine(m.ToString());
            }
            Console.WriteLine(FiboCalculator.Equals(10, 0.0));
            Console.WriteLine("***Fun With Conversions ***");
            int myInt = 12345678;
            myInt.DisplayDefiningAssembly();
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.DisplayDefiningAssembly();

           Console.WriteLine( myInt.ReverseDigits());
           Console.WriteLine("扩展接口测试");
           string[] data = { "Wow", "this", "is ", "sort", "of", "annoying", "but", "in", "a", "weird", "way", "fun" };
           data.PrintDataAndBeep();
                Rectangle r=new Rectangle(5,4);
            Console.WriteLine(r.ToString());
            r.Draw();
            Square s = (Square)r;
            Console.WriteLine(s.ToString());
            s.Draw();
            Console.WriteLine(GC.GetTotalMemory(false)+"---"+GC.MaxGeneration);
          //  Console.ReadLine();
            BuildAnonType("BWM", "red", 1234);
        }
开发者ID:red201432,项目名称:CSharpLearn,代码行数:28,代码来源:Program.cs


示例5: PopulateEmployerGroupDDL

        public void PopulateEmployerGroupDDL()
        {
            dbProcedures db = new dbProcedures();

            try
            {
                System.Data.SqlClient.SqlCommand sqlCmd = new System.Data.SqlClient.SqlCommand("SELECT DISTINCT EmployerGroup FROM tbl_Members ORDER BY EmployerGroup", new db().SqlConnection);
                sqlCmd.CommandType = System.Data.CommandType.Text;

                System.Data.DataTable loadReaderdata = new System.Data.DataTable();
                loadReaderdata.Load(sqlCmd.ExecuteReader());

                ddlEmployerGroup.DataSource = loadReaderdata;
                ddlEmployerGroup.DataTextField = "EmployerGroup";
                ddlEmployerGroup.DataValueField = "EmployerGroup";
                ddlEmployerGroup.DataBind();

                ddlEmployerGroup.Items.Insert(0, new ListItem("", ""));
                ddlEmployerGroup.SelectedIndex = 0;

            }
            catch (Exception ex)
            {
                db.LogAction("", "Error", "Error loading Members UI page. " + ex.Message.ToString());
            }

            db.Close();
        }
开发者ID:reagan83,项目名称:EOBSystemAdmin,代码行数:28,代码来源:Members.aspx.cs


示例6: GetCSVTest

        public void GetCSVTest()
        {
            var datatable = new System.Data.DataTable();
            datatable.Columns.Add("Col1", typeof (string));
            datatable.Columns.Add("Co12", typeof (string));
            datatable.Rows.Add("A", "ł");
            datatable.Rows.Add("ą", "ä");

            string failure = null;
            var thread = new System.Threading.Thread(() =>
                                                         {
                                                             var dataobject =
                                                                 System.Windows.Forms.Clipboard.GetDataObject();
                                                             Isotope.Clipboard.ClipboardUtil.SetDataCSVFromTable(
                                                                 dataobject, datatable);
                                                             System.Windows.Forms.Clipboard.SetDataObject(dataobject);

                                                             var out_csv = Isotope.Clipboard.ClipboardUtil.GetCSV();
                                                             System.Windows.Forms.Clipboard.Clear();
                                                         });
            thread.SetApartmentState(System.Threading.ApartmentState.STA);
            thread.Start();
            thread.Join();
            if (failure != null)
            {
                Assert.Fail();
            }
        }
开发者ID:saveenr,项目名称:saveenr,代码行数:28,代码来源:ClipboardUtilTest.cs


示例7: TestOracleConn

//        public string CreateMYSQLModel(string DBName, string NameSpaceName, string TableName, string outputFilePath)
//        {
//            if (string.IsNullOrEmpty(DBName) || string.IsNullOrEmpty(NameSpaceName) || string.IsNullOrEmpty(TableName) || string.IsNullOrEmpty(outputFilePath))
//                return "";
//            Session.Session mysql = Session.SessionFactory.GetMySQL();

//            List<TableModel> tbs = mysql.FindAll<TableModel>(@"SELECT COLUMN_NAME,IS_NULLABLE,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,COLUMN_COMMENT
// FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='" + DBName + "' AND TABLE_NAME='" + TableName + "' ;");

//            List<KEYModel> keys = mysql.FindAll<KEYModel>(@"SELECT b.COLUMN_NAME,b.DATA_TYPE FROM information_schema.KEY_COLUMN_USAGE a
// inner join information_schema.COLUMNS b on a.TABLE_SCHEMA=b.TABLE_SCHEMA and a.COLUMN_NAME=b.COLUMN_NAME and a.TABLE_NAME=b.TABLE_NAME
// WHERE a.TABLE_SCHEMA='" + DBName + "'  AND a.TABLE_NAME='" + TableName + "' and a.CONSTRAINT_NAME='PRIMARY'; ");

//            return OutPutStr(tbs, keys, NameSpaceName, TableName, outputFilePath);
//        }

        public string TestOracleConn()
        {

            //Session.Session oracle = Session.SessionFactory.GetOracle();

            //Session.Session sql = Session.SessionFactory.GetSQLServer();


            System.Data.DataTable sds = new System.Data.DataTable();
            //sds = oracle.FindAll("select * from INFORMATION ").Tables[0];

            //List<CONFERENCE> tbs = sql.FindAll<CONFERENCE>(@"SELECT * FROM Conference");
            //List<INFORMATION_Oracle> tbs2 = oracle.FindAll<INFORMATION_Oracle>(@"SELECT * FROM INFORMATION");


            int isOk = 0;
            //for (int i = 0; i < tbs.Count; i++)
            //{
                //ParamMap param = oracle.newMap();
                //param.Add("CONFERENCE_ID", tbs[i].ConferenceId);
                //param.Add("CONTENTS", tbs[i].Contents);
                //string sqlStr = "update CONFERENCE set CONTENTS=:CONTENTS  where CONFERENCE_ID=:CONFERENCE_ID ";
                // > 0;

                //CONFERENCE_Oracle o_info = oracle.FindByID<CONFERENCE_Oracle>(tbs[i].ConferenceId.ToString());
                //o_info.CONTENTS = tbs[i].Contents;
                //isOk += oracle.Update<CONFERENCE_Oracle>(o_info);

                //    oracle.ExcuteSQL(sqlStr, param);
                //o_info.INFO_ID = "2015060916531897637858e973c8bb9";
           // }
            return isOk.ToString();
        }
开发者ID:lee8775,项目名称:DotNetRESTful,代码行数:49,代码来源:Tools.cs


示例8: DataReaderToDataTable

		public System.Data.DataTable DataReaderToDataTable(MySqlDataReader Reader)
		{
			System.Data.DataTable dt = new System.Data.DataTable();
			System.Data.DataColumn dc;
			System.Data.DataRow dr;
			ArrayList arr = new ArrayList();
			int i;

			for(i=0;i<Reader.FieldCount;i++)
			{
				dc = new System.Data.DataColumn();

				dc.ColumnName = Reader.GetName(i);					
				arr.Add(dc.ColumnName);

				dt.Columns.Add(dc);
			}
			
			while(Reader.Read())
			{
				dr = dt.NewRow();

				for (i=0;i<Reader.FieldCount;i++)
				{
					dr[(string)arr[i]] = Reader[i].ToString();
				}
				dt.Rows.Add(dr);
			}

			Reader.Close();
			return dt;
		}
开发者ID:marioricci,项目名称:erp-luma,代码行数:32,代码来源:DataClass.cs


示例9: Insert

		public Int64 Insert(ProductGroupUnitsMatrixDetails Details)
		{
			try 
			{
                Save(Details);

                string SQL = "SELECT LAST_INSERT_ID();";
	 			
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID");
                base.MySqlDataAdapterFill(cmd, dt);

                Int64 iID = 0;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int64.Parse(dr[0].ToString());
                }					

				return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
开发者ID:marioricci,项目名称:erp-luma,代码行数:29,代码来源:ProductGroupUnitsMatrix.cs


示例10: calculateStringOperation

        private static string calculateStringOperation(string[] temp)
        {
            // First things first!
            string operationString = "";
            string tempVar;
            bool errorFlag = false;

            for (int i = 0; i < temp.Length; i++)
            {
            if (temp[i].Equals(".add.")) { temp[i] = " + "; }
            else if (temp[i].Equals(".sub.")) { temp[i] = " - "; }
            else if (temp[i].Equals(".mul.")) { temp[i] = " * "; }
            else if (temp[i].Equals(".div.")) { temp[i] = " / "; }
            else if (isVariableName(temp[i])) {
                if (variables.ContainsKey(temp[i])) { variables.TryGetValue(temp[i], out tempVar); temp[i] = tempVar; }
                else if (!variables.ContainsKey(temp[i])) { errorFlag = true; }
            }
            else if (isString(temp[i])) { temp[i] = temp[i].Replace('"', '\''); }
            }

            foreach (string s in temp) { operationString += s; }
            //Console.WriteLine(operationString);
            if (!errorFlag)
            {
            var result = new System.Data.DataTable().Compute(operationString, null).ToString();
            //ExpressionEval expr = new ExpressionEval(operationString);
            //object result = expr.Evaluate();
            //Console.WriteLine("Test: " + result);
            return result; //(string)result;
            }
            else
            {
            return null;
            }
        }
开发者ID:TakoArishi,项目名称:LAOInterpreter,代码行数:35,代码来源:LAOInterpreter.cs


示例11: GetAllBenchmarks

        private System.Data.DataTable GetAllBenchmarks()
        {
            HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
            //HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.Load(@"");
            HtmlAgilityPack.HtmlDocument doc = web.Load(@"http://benchmarksgame.alioth.debian.org/");

            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Url", typeof(string));

            System.Data.DataRow dr = null;

            foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//section[1]//li/a[@href]"))
            {
                dr = dt.NewRow();
                // System.Console.WriteLine(link);
                dr["Name"] = System.Web.HttpUtility.HtmlDecode(link.InnerText);
                dr["Url"] = link.Attributes["href"].Value;

                dt.Rows.Add(dr);
            } // Next link

            System.Data.DataView dv = dt.DefaultView;
            dv.Sort = "Name ASC";
            System.Data.DataTable sortedDT = dv.ToTable();

            return sortedDT;
        }
开发者ID:ststeiger,项目名称:AliothBenchmarkDataExtract,代码行数:29,代码来源:Form1.cs


示例12: GetData

        private System.Data.DataTable GetData(int city, string lang)
        {
            try
            {
                SqlConnection myConnection = new SqlConnection("user id=Uib;" +
                                     "password=Uib;server=localhost;" +
                                     "Trusted_Connection=yes;" +
                                     "database=Uib; " +
                                     "connection timeout=30");
                myConnection.Open();
                var command = new SqlCommand("GET_HOTELS_BY_CITY", myConnection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@city", city);
                command.Parameters.AddWithValue("@lang", lang);
                SqlDataReader reader = command.ExecuteReader();
                var dataTable = new System.Data.DataTable();

                dataTable.Load(reader);
                reader.Close();
                myConnection.Close();
                return dataTable;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            return null;
        }
开发者ID:LogitravelUIB,项目名称:Logitravel-Mvc,代码行数:28,代码来源:HotelController.cs


示例13: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            System.Data.DataTable world = new System.Data.DataTable("World Population");
            world.Columns.AddRange(new System.Data.DataColumn[] {
                new System.Data.DataColumn("Country",typeof(string)),
                new System.Data.DataColumn("Population",typeof(int))
            });
            world.Rows.Add(new object[] { "Germany", 200 });
            world.Rows.Add(new object[] { "United States", 350 });
            world.Rows.Add(new object[] { "Brazil", 250 });
            world.Rows.Add(new object[] { "Canada", 75 });
            world.Rows.Add(new object[] { "France", 290 });
            world.Rows.Add(new object[] { "Russia", 700 });
            world.Rows.Add(new object[] { "China", 1300 });
            world.Rows.Add(new object[] { "India", 1000 });

            this.GVGeoMap1.GviRegion = GoogleChartsNGraphsControls.MapRegion.World;
            this.GVGeoMap1.GviDisplayMode = GoogleChartsNGraphsControls.MapDisplayModes.Regions;
            this.GVGeoMap1.GviColors = new Color?[] { Color.Blue, Color.Cornsilk, Color.DarkMagenta, Color.DarkTurquoise, Color.FloralWhite };
            this.GVGeoMap1.DataSource = world;

            System.Data.DataTable projs = new System.Data.DataTable("US Projects");
            projs.Columns.AddRange(new System.Data.DataColumn[] {
                new System.Data.DataColumn("City",typeof(string)),
                new System.Data.DataColumn("Completion",typeof(int)),
                new System.Data.DataColumn("Comments",typeof(string))
            });
            projs.Rows.Add(new object[] { "Astoria, NY", 95, "Astoria: Almost Done" });
            projs.Rows.Add(new object[] { "Novato, CA", 35, "Novato: Just Starting" });
            projs.Rows.Add(new object[] { "Duvall, WA", 10, "Duvall: Just Starting" });

            this.GVGeoMap2.GviOptionsOverride = "{'region':'US','colors':[0xFF8747, 0xFFB581, 0xc06000], 'dataMode':'markers'}";
            this.GVGeoMap2.DataSource = projs;
        }
开发者ID:JulsMan,项目名称:googlevisualizationsdotnet,代码行数:34,代码来源:GeoMaps.aspx.cs


示例14: DataGrid_Initialized

        private void DataGrid_Initialized(object sender, System.EventArgs e)
        {
            // TODO: Delete all this code and replace it with a simple query when database is available.

            SourceDataTable = new System.Data.DataTable("Priorities");
            SourceDataTable.Columns.Add(new System.Data.DataColumn("ID", System.Type.GetType("System.Int32")));
            SourceDataTable.Columns.Add(new System.Data.DataColumn("Name", System.Type.GetType("System.String")));
            SourceDataTable.Columns.Add(new System.Data.DataColumn("Value", System.Type.GetType("System.Int32")));
            SourceDataTable.Columns.Add(new System.Data.DataColumn("Active", System.Type.GetType("System.Boolean")));

            System.Action<int, string, int, bool> AddNewRow = (id, name, value, active) =>
                {
                    var row = SourceDataTable.NewRow();
                    row["ID"] = id;
                    row["Name"] = name;
                    row["Value"] = value;
                    row["Active"] = active;
                    SourceDataTable.Rows.Add(row);
                };

            AddNewRow(1, "Haute", 1, true);
            AddNewRow(2, "Moyenne", 2, true);
            AddNewRow(3, "Faible", 3, true);

            Save();
        }
开发者ID:xeph,项目名称:LOG350.TP3,代码行数:26,代码来源:Priorities.xaml.cs


示例15: Insert

		public Int32 Insert(AccountCategoryDetails Details)
		{
			try 
			{
                Save(Details);

                string SQL = "SELECT LAST_INSERT_ID();";
				  
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                Int32 iID = 0;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int32.Parse(dr[0].ToString());
                }

                return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
开发者ID:marioricci,项目名称:erp-luma,代码行数:30,代码来源:AccountCategory.cs


示例16: ConsultaMySQL

        public System.Data.DataTable ConsultaMySQL(String query,MySqlParameterCollection parametros,System.Data.CommandType tipo_comando)
        {
            System.Data.DataTable tabla = new System.Data.DataTable();
            try {

            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand comando = new MySqlCommand(query, canal);
            comando.CommandType = tipo_comando;
            if (parametros != null)
            {
                foreach (var item in parametros)
                {
                    comando.Parameters.Add(item);

                }
            }

            adapter.SelectCommand = comando;
            adapter.Fill(tabla);
            if (tabla.Rows.Count > 0)
            {
                return tabla;
            }
            else {
                return null;
            }

            }
            catch (Exception er) { MessageBox.Show("error: " + er.Message); return null; }
        }
开发者ID:azulm95,项目名称:Sistema_ventas,代码行数:30,代码来源:Conexion.cs


示例17: ToCSV

        public static void ToCSV(string path, string[,] data)
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            int row = data.GetLength(0);
            int column = data.GetLength(1);
            for (int j = 0; j < column; j++)
            {
                dt.Columns.Add(data[0, j], typeof(String));
            }

            for (int i = 0; i < row; i++)   //含表头
            {
                dt.Rows.Add(dt.NewRow());
                for (int j = 0; j < column; j++)
                {
                    if (!String.IsNullOrEmpty(data[i, j]))
                    {
                        dt.Rows[i][j] = "\"" + data[i, j].Replace("\"", "\"\"") + "\"";
                    }
                }
            }
            dt.AcceptChanges();

            CsvOptions options = new CsvOptions("String[,]", ',', data.GetLength(1));
            CsvEngine.DataTableToCsv(dt, path, options);
        }
开发者ID:niceplayer454,项目名称:cfi,代码行数:27,代码来源:CsvHelper.cs


示例18: GetDataTable

        public static System.Data.DataTable GetDataTable(string strSQL)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            System.Data.SqlClient.SqlConnectionStringBuilder csb = new System.Data.SqlClient.SqlConnectionStringBuilder();

            csb.DataSource = System.Environment.MachineName;
            csb.DataSource = @"VMSTZHDB08\SZH_DBH_1";
            csb.InitialCatalog = "HBD_CAFM_V3";

            csb.DataSource = "CORDB2008R2";
            csb.InitialCatalog = "Roomplanning";

            // csb.DataSource = "cordb2014";
            // csb.InitialCatalog = "ReportServer";

            csb.DataSource = @"CORDB2008R2";
            csb.InitialCatalog = "COR_Basic_SwissLife";

            csb.IntegratedSecurity = true;

            using (System.Data.Common.DbDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(strSQL, csb.ConnectionString))
            {
                da.Fill(dt);
            }

            return dt;
        }
开发者ID:ststeiger,项目名称:ReportViewerWrapper,代码行数:27,代码来源:SQL.cs


示例19: recuperaLista

        public static System.Data.DataTable recuperaLista(DespesaUnidadeOrcamentaria desp)
        {
            string sql = "select uo.undnome, despCod, cc.cennome, despJan, despFev, despMar, despAbr, despMai, despJun," +
                            "despJul, despAgo, despSet, despOut, despNov, despDez, uo.undUnificado,uo.undCodigo,uo.undCodOrgao " +
                            "from " +
                            "despesaunidadeorcamentaria DUO " +
                            "join unidadeorcamentaria UO on uo.undcodorgao = duo.despunorgao and uo.undcodigo = duo.despunidade " +
                            "join centrocusto cc on cc.cencod = duo.despcencod " +
                            "where uo.undcodigo = '" + desp.UndOrca.undCodigo + "' and uo.undcodorgao = '" + desp.UndOrca.Org.orgCodigo + "'";

            System.Data.DataTable table = new System.Data.DataTable();
            table.Columns.Add("#", typeof(string));
            table.Columns.Add("Unidade", typeof(string));
            table.Columns.Add("Centro Custo", typeof(string));
            table.Columns.Add("JAN", typeof(string));
            table.Columns.Add("FEV", typeof(string));
            table.Columns.Add("MAR", typeof(string));
            table.Columns.Add("ABR", typeof(string));
            table.Columns.Add("MAI", typeof(string));
            table.Columns.Add("JUN", typeof(string));
            table.Columns.Add("JUL", typeof(string));
            table.Columns.Add("AGO", typeof(string));
            table.Columns.Add("SET", typeof(string));
            table.Columns.Add("OUT", typeof(string));
            table.Columns.Add("NOV", typeof(string));
            table.Columns.Add("DEZ", typeof(string));
            System.Data.DataTable dt = AcessoDados.AcessoDados.dtable(sql);
            foreach (System.Data.DataRow linha in dt.Rows)
            {
                if(!(linha["DespJan"].ToString().Equals("0") && linha["DespFev"].ToString().Equals("0") && linha["DespMar"].ToString().Equals("0") && linha["DespAbr"].ToString().Equals("0") && linha["DespMai"].ToString().Equals("0") && linha["DespJun"].ToString().Equals("0") && linha["DespJul"].ToString().Equals("0") && linha["DespAgo"].ToString().Equals("0") && linha["DespSet"].ToString().Equals("0") && linha["DespOut"].ToString().Equals("0") && linha["DespNov"].ToString().Equals("0") && linha["DespDez"].ToString().Equals("0"))){
                    table.Rows.Add(linha["despCod"].ToString(),linha["undnome"].ToString(),  linha["cennome"].ToString(), float.Parse(linha["DespJan"].ToString()).ToString("N"), float.Parse(linha["DespFev"].ToString()).ToString("N"), float.Parse(linha["DespMAR"].ToString()).ToString("N"), float.Parse(linha["DespABR"].ToString()).ToString("N"), float.Parse(linha["DespMAI"].ToString()).ToString("N"), float.Parse(linha["DespJUN"].ToString()).ToString("N"), float.Parse(linha["DespJUL"].ToString()).ToString("N"), float.Parse(linha["DespAGO"].ToString()).ToString("N"), float.Parse(linha["DespSET"].ToString()).ToString("N"), float.Parse(linha["DespOUT"].ToString()).ToString("N"), float.Parse(linha["DespNOV"].ToString()).ToString("N"), float.Parse(linha["DespDEZ"].ToString()).ToString("N"));
                }
            }
            return table;
        }
开发者ID:EmersonBessa,项目名称:FluxusWeb,代码行数:35,代码来源:DespesaUnidadeOrcamentariaCtrl.cs


示例20: of_GetGoocodeToUseCity

 /// <summary>
 /// 返回当前客户所在省区下的指定产品已有经销商的城市
 /// </summary>
 /// <param name="as_cusCode">客户编号</param>
 /// <param name="as_gooCode">商品编号</param>
 /// <returns></returns>
 public static string of_GetGoocodeToUseCity(string as_cusCode, string as_gooCode)
 {
     if (string.IsNullOrEmpty(as_cusCode) || string.IsNullOrEmpty(as_gooCode))
         return "";
     string ls_sql_prov = "select cus_prov from customer where cus_code='" + as_cusCode + "'";
     string ls_prov = "";
     ls_prov = SqliteHelper.ExecuteScalar(ls_sql_prov);
     if (string.IsNullOrEmpty(ls_prov))
         return "";
     string ls_sql_use = @"select cityname from city where cityno in (select cus_city 
                       from oldsaleprice,goodsno,customer 
                       where oldsaleprice.cus_code=customer.cus_code 
                       and [email protected]_prov 
                       and oldsaleprice.goo_code=goodsno.goo_code 
                       and [email protected]_code 
                       group by cus_city)";
     ls_sql_use = ls_sql_use.Replace("@cus_prov", "'" + ls_prov + "'");
     ls_sql_use = ls_sql_use.Replace("@goo_code", "'" + as_gooCode + "'");
     System.Data.DataTable ldt_use = new System.Data.DataTable();
     ldt_use = SqliteHelper.ExecuteDataTable(ls_sql_use);
     if (ldt_use == null)
         return "";
     if (ldt_use.Rows.Count == 0)
         return "";
     string ls_use = "";
     for (int i = 0; i < ldt_use.Rows.Count; i++)
     {
         if (i == ldt_use.Rows.Count - 1)
             ls_use += ldt_use.Rows[i]["cityname"] == null ? "" : ldt_use.Rows[i]["cityname"].ToString() + "";
         else
             ls_use += ldt_use.Rows[i]["cityname"] == null ? "" : ldt_use.Rows[i]["cityname"].ToString() + ",";
     }
     return ls_use;
 }
开发者ID:eatage,项目名称:AppTest,代码行数:40,代码来源:Tools.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Metadata.Edm类代码示例发布时间:2022-05-24
下一篇:
C# Data.DataSet类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap