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


C# DataSet.HasChanges方法代码示例

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


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

示例1: run

	//Activate This Construntor to log All To Standard output
	//public TestClass():base(true){}

	//Activate this constructor to log Failures to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, false){}


	//Activate this constructor to log All to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, true){}

	//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES

	public void run()
	{
		Exception exp = null;
	
		DataSet ds = new DataSet();
		ds.Tables.Add(GHTUtils.DataProvider.CreateParentDataTable());

		try
		{
			BeginCase("HasChanges 1");
			Compare(ds.HasChanges(),false );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}
		
		DataRow dr = ds.Tables[0].NewRow();
		dr[0] = 9;
		ds.Tables[0].Rows.Add(dr);
		
		try
		{
			BeginCase("HasChanges 2");
			Compare(ds.HasChanges(),true );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}
	}
开发者ID:nlhepler,项目名称:mono,代码行数:39,代码来源:DataSet_HasChanges.cs

示例2: CounterForm

        public CounterForm()
        {
            InitializeComponent();

            LoginForm form = new LoginForm();

            toolStripStatusLabel_UserName.Text = form.GetUserName();
            toolStripStatusLabel_UserType.Text = form.GetUserType();
            toolStripStatusLabel_Date.Text = DateTime.Today.ToLongDateString();

            ds = new DataSet();
            rentDAL = new Renting_Management_System.DAL.RentDAL();

            ds = rentDAL.GetAll();
            bindingSource = new BindingSource();
            bindingSource.DataSource = ds;
            bindingSource.DataMember = ds.Tables[0].TableName;
            bindingSource.Sort = ds.Tables[0].Columns[0].ColumnName + " ASC";
            dataGridView1.DataSource = bindingSource;
            bindingNavigator1.BindingSource = bindingSource;
            dataGridView1.Columns[0].ReadOnly = true;
            dataGridView1.Columns[1].ReadOnly = true;
            dataGridView1.Columns[2].ReadOnly = true;
            bindingNavigatorAddNewItem.Enabled = false;
            bindingNavigatorDeleteItem.Enabled = false;
            if (ds.HasChanges())
            {
                toolStripButton_Save.Enabled = true;
                changed = true;
            }
        }
开发者ID:orgonil,项目名称:rent-management-system,代码行数:31,代码来源:CounterForm.cs

示例3: fatch2

        void fatch2()
        {
            DataSet ds = new DataSet();
            ds.ReadXml(s + "\\visible.xml");
            if (ds != null && ds.HasChanges())
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    listBox1.Items.Add(ds.Tables[0].Rows[i][0].ToString());

                }

            }
        }
开发者ID:spsinghdocument1,项目名称:some,代码行数:14,代码来源:RepositionColumns.cs

示例4: Get_Xml

        void Get_Xml()
        {
            DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath("~/Quotes.xml"));
            if (ds != null && ds.HasChanges())
            {
                XmlGridView.DataSource = ds;
                XmlGridView.DataBind();
            }
            else
            {
                XmlGridView.DataBind();
            }

        }
开发者ID:HiramRangel,项目名称:Measure-IT,代码行数:15,代码来源:testing.aspx.cs

示例5: UpdateDataSet

 private void UpdateDataSet(DataSet dataSet)
 {
     if (!dataSet.HasChanges(DataRowState.Modified))
     {
         return;
     }
     DataSet tempDataSet = dataSet.GetChanges(DataRowState.Modified);
     if (tempDataSet.HasErrors)
     {
         MessageBox.Show("Data has Errors");
     }
     else
     {
         tableAdapterManager.UpdateAll(tempDataSet);
     }
 }
开发者ID:rsschindler,项目名称:ConnectCEMS,代码行数:16,代码来源:MediaBagScan.cs

示例6: datagrFATCH

        void datagrFATCH()
        {
            string b="";
            DataSet ds = new DataSet();
            ds.ReadXml(s + "\\visible.xml");
            if (ds != null && ds.HasChanges())
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                     b = ds.Tables[0].Rows[i][0].ToString();

                   // comboBox1.Items.Add(ds.Tables[0].Rows[i][0].ToString());
                   // dataGridView1.Columns.Add(ds.Tables[0].Rows[i][0].ToString());
                     dataGridView1.Columns.Add("h", b.ToString());
                     dataGridView1.Rows.Add("f");

                }

            }
        }
开发者ID:spsinghdocument1,项目名称:some,代码行数:20,代码来源:Form1.cs

示例7: OnBeforeApplyUpdates

        protected void OnBeforeApplyUpdates(EventArgs value)
        {
            EventHandler handler = (EventHandler)base.Events[EventOnBeforeApplyUpdates];
            if (handler != null)
            {
                handler(this, value);
            }

            DataTable mergeTab = new DataTable();
            DataSet mergedataset = new DataSet();
            DataSet ds = new DataSet();
            if (this.Container != null)
            {
                int i = this.Container.Components.Count;
                for (int j = 0; j < i; j++)
                {
                    if (this.Container.Components[j] is InfoBindingSource)
                    {
                        InfoBindingSource bs = (InfoBindingSource)this.Container.Components[j];
                        int m = bs.Relations.Count;
                        for (int n = 0; n < m; n++)
                        {
                            InfoRelation infoRel = bs.Relations[n];
                            ds = this.fRealDataSet;
                            if (infoRel.RelationDataSet.GetRealDataSet() == ds)
                            {
                                if (ds.HasChanges())
                                {
                                    string strTabName = this.RemoteName.Substring(this.RemoteName.IndexOf('.') + 1);
                                    mergeTab = ds.GetChanges().Tables[strTabName];
                                    mergedataset = ds.GetChanges();
                                    if (((InfoDataSet)bs.GetDataSource()).RealDataSet.Tables[0].Rows.Count == 0)
                                    {
                                        bs.Set_fEmptyViewMerge();
                                    }
                                    //2008/8/4 by ccm, 解决最后一笔无法删除的问题,取消DoDelay事件,避免触发使master重新取资料变为unchanged,导致无法删除。
                                    bs.CancelPositionChanged = true;
                                    ((InfoDataSet)bs.GetDataSource()).RealDataSet.Tables[0].Merge(mergeTab);
                                    bs.CancelPositionChanged = false;

                                    //2008-9-9 Modified by lily 最後一筆master無法删除的問題。View在merge后master的資料會不見,重新merge一次master。
                                    if (mergeTab.Rows.Count > 0 && mergeTab.Rows[0].RowState == DataRowState.Deleted)
                                    {
                                        //2007/01/12 Master-Detail-View因为无法删除最后一笔资料而新增 by Rax
                                        ds.Tables[strTabName].Merge(mergeTab);

                                        foreach (DataTable tb in ds.Tables)
                                        {
                                            if (mergedataset.Tables[tb.TableName] != null)
                                            {
                                                tb.Merge(mergedataset.Tables[tb.TableName]);
                                            }
                                        }
                                        //2007/01/12 end
                                    }
                                    ArrayList keyFields = this.GetKeyFields();
                                    int p = mergeTab.Rows.Count - 1;
                                    if (p >= 0 && (mergeTab.Rows[p].RowState == DataRowState.Added || mergeTab.Rows[p].RowState == DataRowState.Modified))
                                    {
                                        int x = keyFields.Count;
                                        object[] keyValues = new object[x];
                                        for (int y = 0; y < x; y++)
                                        {
                                            keyValues[y] = mergeTab.Rows[p][keyFields[y].ToString()];
                                        }
                                        DataRow locRow = ((InfoDataSet)bs.GetDataSource()).RealDataSet.Tables[0].Rows.Find(keyValues);
                                        if (locRow != null)
                                        {
                                            int a = bs.List.Count;
                                            for (int b = 0; b < a; b++)
                                            {
                                                if (((DataRowView)bs.List[b]).Row == locRow)
                                                {
                                                    // 2006/08/05 將View BindingSource.Relation.Active設  為False,Find()完後, 再設為True
                                                    if (infoRel.Active)
                                                    {
                                                        RelationsActive = true;
                                                        infoRel.Active = false;
                                                    }
                                                    // 2006/08/05

                                                    //2008/9/4 modified by ccm在新增的時候會插入最後一筆,導致取下一批資料
                                                    bs.CancelPositionChanged = true;
                                                    bs.Position = b;
                                                    bs.CancelPositionChanged = false;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
开发者ID:san90279,项目名称:UK_OAS,代码行数:98,代码来源:InfoDataSet.cs

示例8: select

        /// </summary>
        void select()
        {
            string b = "";
            string c = "";

            DataSet ds = new DataSet();

            ds.ReadXml(s + "\\RepositionColumns.xml");
            if (ds != null && ds.HasChanges())
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    b = ds.Tables[0].Rows[i][0].ToString();

                       dataGridView1.Rows.Add(b.ToString());

                }

                //////////////////////////////////////////////////////////////////////////////////////////////////////

              //  dataGridView1.Rows.Add(b.ToString());
                //////////////////////////////////////////////////////////////////////////////////////////////////////////

            }
        }
开发者ID:spsinghdocument1,项目名称:some,代码行数:26,代码来源:Select.cs

示例9: select_sho

        /// <summary>
        /// /////////////////////////////////////////////////////////////////////////////
        public void select_sho(string PORTFOLIO2)
        {
            string PORTFOLIO = "PARAMETER";
            DataSet ds = new DataSet();
            string s = Application.StartupPath;
            string path = s + "\\InsertToken.xml";
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
            XmlNode node = doc.SelectSingleNode("//TokensDetails/Token[ parameter='" + PORTFOLIO + "']");
            string parameter = (node.SelectSingleNode("parameter").InnerText);
            string portfolio = (node.SelectSingleNode("portfolio").InnerText);
            string AddTokenn = (node.SelectSingleNode("AddTokenn").InnerText);
            dataGridView2.Columns.Add(parameter, parameter);
            dataGridView2.Columns.Add(portfolio, portfolio);
            for (int i = 1; i <= Convert.ToInt64(AddTokenn); i++)
            {
                dataGridView2.Columns.Add("Token_" + i, "Token_" + i);
            }

            ///////////////////////////////////////////////////////////////////////////////////////////

            DataSet ds2 = new DataSet();
            ds2.ReadXml(s + "\\UserInput.xml");
            if (ds2 != null && ds2.HasChanges())
            {
                string datagrd = "";
                for (int i = -1; i < ds2.Tables[0].Rows.Count; i++)
                {

                    if (i == 0 || i == -1)
                    {

                    }
                    else
                    {
                        // datagrd = datagrd + ds2.Tables[0].Rows[i][0].ToString();
                        datagrd = ds2.Tables[0].Rows[i][0].ToString();
                    }

                    dataGridView2.Rows.Add(datagrd.ToString());
                }

            }

            ///////////////////////////////////////////////////////////////////////////////////

            label1.Text = PORTFOLIO2;
            string ab = "";
            dataGridView2.Rows[0].Cells[1].Value = PORTFOLIO2;

            string path2 = s + "\\UserView2.xml";
            XmlDocument doc2 = new XmlDocument();
            doc2.Load(path2);
            XmlNode node2 = doc2.SelectSingleNode("//User_Parameters/Parameters[ portfalio='" + PORTFOLIO2 + "']");

            dataGridView2.Rows[0].Cells[0].Value = (node2.SelectSingleNode("PARAMETER").InnerText);
            dataGridView2.Rows[0].Cells[2].Value = (node2.SelectSingleNode("Token_1").InnerText);
            dataGridView2.Rows[0].Cells[3].Value = (node2.SelectSingleNode("Token_2").InnerText);
            dataGridView2.Rows[2].Cells[1].Value = (node2.SelectSingleNode("MAXQTY").InnerText);
            dataGridView2.Rows[3].Cells[1].Value = (node2.SelectSingleNode("BNSFOIFF").InnerText);
            dataGridView2.Rows[4].Cells[1].Value = (node2.SelectSingleNode("BFNSQTY").InnerText);
        }
开发者ID:spsinghdocument1,项目名称:some,代码行数:64,代码来源:Modfy.cs

示例10: inert

        /////////////////////////////////////////////////////////////////////////////////////  Edit  //////////////////////////////
        void inert()
        {
            string parameter = "", portfalioo = "", Token = "", user = "";
            string datagrd = "";
            parameter = (string)dataGridView2.Rows[0].Cells[0].Value;
            portfalioo = (string)dataGridView2.Rows[0].Cells[1].Value;
            if (portfalioo == null)
            {
                MessageBox.Show("Please Insert portfalio");
                return;
            }
            ////////////////////////////////////////////////////////////////////
            XmlDocument MyXmlDocument = new XmlDocument();
            MyXmlDocument.Load(Application.StartupPath + "\\UserView2.xml");
            XmlElement ParentElement = MyXmlDocument.CreateElement("Parameters");
            XmlElement PARAMETER = MyXmlDocument.CreateElement("PARAMETER");
            PARAMETER.InnerText = parameter;
            XmlElement portfalio = MyXmlDocument.CreateElement("portfalio");
            portfalio.InnerText = portfalioo;
            ParentElement.AppendChild(PARAMETER);
            ParentElement.AppendChild(portfalio);

            //////////////////////////////////////////// TOken ADD  ////////////////////////

            string PORTFOLIO = "PARAMETER";
            DataSet ds = new DataSet();
            string s = Application.StartupPath;
            string path = s + "\\InsertToken.xml";
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
            XmlNode node = doc.SelectSingleNode("//TokensDetails/Token[ parameter='" + PORTFOLIO + "']");
            string AddTokenn = (node.SelectSingleNode("AddTokenn").InnerText);
            for (int i = 1; i <= Convert.ToInt64(AddTokenn); i++)
            {
                // dataGridView1.Columns.Add("Token_" + i, "Token_" + i);
                Token = Convert.ToString("Token_" + i);
                XmlElement pToken = MyXmlDocument.CreateElement(Token);

                Token = (string)dataGridView2.Rows[0].Cells[1 + i].Value;
                pToken.InnerText = Token;
                ParentElement.AppendChild(pToken);

            }
            ////////////////////////////////////////////////////////////////////////// User Add  //////////////////
            DataSet ds2 = new DataSet();

            ds2.ReadXml(s + "\\UserInput.xml");
            if (ds2 != null && ds2.HasChanges())
            {

                for (int i = 1; i < ds2.Tables[0].Rows.Count; i++)
                {

                    //if (i == 0 || i == -1)
                    //{

                    //}
                    //  else
                    // {
                    datagrd = Convert.ToString(ds2.Tables[0].Rows[i][0].ToString());

                    XmlElement datagrdd = MyXmlDocument.CreateElement(datagrd.Replace(" ", ""));

                    user = (string)dataGridView2.Rows[1 + i].Cells[1].Value;
                    datagrdd.InnerText = user;
                    ParentElement.AppendChild(datagrdd);
                    //}

                    //dataGridView1.Rows.Add(""+datagrd.ToString());
                }

            }

            ////////////////////////////////////////////////////////////////////////////////////////////////

            MyXmlDocument.DocumentElement.AppendChild(ParentElement);
            MyXmlDocument.Save(Application.StartupPath + "\\UserView2.xml");

            MessageBox.Show("Records Add Successfully");
        }
开发者ID:spsinghdocument1,项目名称:some,代码行数:81,代码来源:Modfy.cs

示例11: updateUserInfo

        public bool updateUserInfo(int userID, Info newInfo)
        {
            SqlConnection loadConnection = new SqlConnection("server=tf-PC\\SQLEXPRESS;database=blogData;uid=admin;pwd=s1y2x3");

            loadConnection.Open();

            string loadString = "SELECT username,headimgID,rgtime,infoID FROM Users WHERE [email protected]";

            SqlCommand loadCommand1 = new SqlCommand(loadString, loadConnection);
            loadCommand1.Parameters.Add(new SqlParameter("userID", SqlDbType.NVarChar, 10));
            loadCommand1.Parameters["userID"].Value = userID;
            SqlDataAdapter loadAdapter = new SqlDataAdapter(loadCommand1);
            DataSet loadDataSet = new DataSet();
            loadAdapter.Fill(loadDataSet, "Users");

            string loadUserInfoString = "SELECT * FROM Info WHERE [email protected]";

            SqlCommand loadCommand3 = new SqlCommand(loadUserInfoString, loadConnection);
            loadCommand3.Parameters.Add(new SqlParameter("infoID", SqlDbType.Int));
            loadCommand3.Parameters["infoID"].Value = loadDataSet.Tables["Users"].Rows[0]["infoID"];
            SqlDataAdapter InfoAdapter = new SqlDataAdapter(loadCommand3);
            InfoAdapter.Fill(loadDataSet, "Info");

            loadDataSet.Tables["Info"].Rows[0]["birthday"] = newInfo.birthday;
            loadDataSet.Tables["Info"].Rows[0]["QQ"] = newInfo.QQ;
            loadDataSet.Tables["Info"].Rows[0]["email"] = newInfo.email;
            loadDataSet.Tables["Info"].Rows[0]["sex"] = newInfo.sex;
            loadDataSet.Tables["Info"].Rows[0]["signtime"] = newInfo.signtime;
            loadDataSet.Tables["Info"].Rows[0]["introduce"] = newInfo.introduce;

            if(loadDataSet.HasChanges())
            {
                try
                {
                    string UpdateCommandString = "SELECT * FROM Info";
                    SqlCommand UpdateCommand = new SqlCommand(UpdateCommandString, loadConnection);
                    SqlDataAdapter UpdateAdapter = new SqlDataAdapter(UpdateCommand);
                    SqlCommandBuilder sb = new SqlCommandBuilder(UpdateAdapter);
                    UpdateAdapter.Update(loadDataSet, "Info");
                }
                catch
                {
                    return false;
                }
            }
            return true;
        }
开发者ID:BrefCool,项目名称:ITBLOGwebsite,代码行数:47,代码来源:blogDataOperate.cs

示例12: SaveDataSet

        // Sauvegarde tous les changements effectué dans le dataset
        public void SaveDataSet(string tableName, DataSet dataSet)
        {
            if (dataSet.HasChanges() == false)
                return;

            switch (connType)
            {
                case ConnectionType.DATABASE_MSSQL:
                    {
                        try
                        {
                            var conn = new SqlConnection(connString);
                            var adapter = new SqlDataAdapter("SELECT * from " + tableName, conn);
                            var builder = new SqlCommandBuilder(adapter);

                            adapter.DeleteCommand = builder.GetDeleteCommand();
                            adapter.UpdateCommand = builder.GetUpdateCommand();
                            adapter.InsertCommand = builder.GetInsertCommand();

                            lock (dataSet) // lock dataset to prevent changes to it
                            {
                                adapter.ContinueUpdateOnError = true;
                                DataSet changes = dataSet.GetChanges();
                                adapter.Update(changes, tableName);
                                PrintDatasetErrors(changes);
                                dataSet.AcceptChanges();
                            }

                            conn.Close();
                        }
                        catch (Exception ex)
                        {
                            throw new DatabaseException("Can not save table " + tableName, ex);
                        }

                        break;
                    }
                case ConnectionType.DATABASE_ODBC:
                    {
                        try
                        {
                            var conn = new OdbcConnection(connString);
                            var adapter = new OdbcDataAdapter("SELECT * from " + tableName, conn);
                            var builder = new OdbcCommandBuilder(adapter);

                            adapter.DeleteCommand = builder.GetDeleteCommand();
                            adapter.UpdateCommand = builder.GetUpdateCommand();
                            adapter.InsertCommand = builder.GetInsertCommand();

                            DataSet changes;
                            lock (dataSet) // lock dataset to prevent changes to it
                            {
                                adapter.ContinueUpdateOnError = true;
                                changes = dataSet.GetChanges();
                                adapter.Update(changes, tableName);
                                dataSet.AcceptChanges();
                            }

                            PrintDatasetErrors(changes);

                            conn.Close();
                        }
                        catch (Exception ex)
                        {
                            throw new DatabaseException("Can not save table ", ex);
                        }

                        break;
                    }
                case ConnectionType.DATABASE_MYSQL:
                    {
                        return;
                    }
                case ConnectionType.DATABASE_OLEDB:
                    {
                        try
                        {
                            var conn = new OleDbConnection(connString);
                            var adapter = new OleDbDataAdapter("SELECT * from " + tableName, conn);
                            var builder = new OleDbCommandBuilder(adapter);

                            adapter.DeleteCommand = builder.GetDeleteCommand();
                            adapter.UpdateCommand = builder.GetUpdateCommand();
                            adapter.InsertCommand = builder.GetInsertCommand();

                            DataSet changes;
                            lock (dataSet) // lock dataset to prevent changes to it
                            {
                                adapter.ContinueUpdateOnError = true;
                                changes = dataSet.GetChanges();
                                adapter.Update(changes, tableName);
                                dataSet.AcceptChanges();
                            }

                            PrintDatasetErrors(changes);

                            conn.Close();
                        }
                        catch (Exception ex)
//.........这里部分代码省略.........
开发者ID:dzikun,项目名称:WarEmu,代码行数:101,代码来源:DataConnection.cs

示例13: show

        void show()
        {
            string PORTFOLIO = "PARAMETER";
            DataSet ds = new DataSet();
            string s = Application.StartupPath;
            string path = s + "\\InsertToken.xml";
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
            XmlNode node = doc.SelectSingleNode("//TokensDetails/Token[ parameter='" + PORTFOLIO + "']");
            string parameter = (node.SelectSingleNode("parameter").InnerText);
            string portfolio = (node.SelectSingleNode("portfolio").InnerText);
            string AddTokenn = (node.SelectSingleNode("AddTokenn").InnerText);
            dataGridView1.Columns.Add(parameter, parameter);
            dataGridView1.Columns.Add(portfolio, portfolio);
            for (int i = 1; i <= Convert.ToInt64(AddTokenn); i++)
            {
                dataGridView1.Columns.Add("Token_" + i, "Token_" + i);
            }

            ///////////////////////////////////////////////////////////////////////////////////////////

            DataSet ds2 = new DataSet();
            ds2.ReadXml(s + "\\UserInput.xml");
            if (ds2 != null && ds2.HasChanges())
            {
                string datagrd = "";
                for (int i = -1; i < ds2.Tables[0].Rows.Count; i++)
                {

                    if (i == 0 || i == -1)
                    {

                    }
                    else
                    {
                       // datagrd = datagrd + ds2.Tables[0].Rows[i][0].ToString();
                        datagrd =  ds2.Tables[0].Rows[i][0].ToString();
                    }

                    dataGridView1.Rows.Add(datagrd.ToString());
                }

            }
        }
开发者ID:spsinghdocument1,项目名称:some,代码行数:44,代码来源:userview.cs

示例14: run

	//Activate This Construntor to log All To Standard output
	//public TestClass():base(true){}

	//Activate this constructor to log Failures to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, false){}


	//Activate this constructor to log All to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, true){}

	//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES

	public void run()
	{
		Exception exp = null;
	
		DataSet ds = new DataSet();
		
		DataRow dr;
		ds.Tables.Add(GHTUtils.DataProvider.CreateParentDataTable());

		try
		{
			BeginCase("HasChanges 1");
			Compare(ds.HasChanges(),false );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		//make some changes

		dr= ds.Tables[0].Rows[1];
		dr.Delete();
        
		dr = ds.Tables[0].Rows[2];
		dr[1] = "NewValue";
		
		dr = ds.Tables[0].Select("","",DataViewRowState.Unchanged)[0];
		
		dr = ds.Tables[0].NewRow();
		dr[0] = 1;
		ds.Tables[0].Rows.Add(dr);
		
		try
		{
			BeginCase("HasChanges Added");
			Compare(ds.HasChanges(DataRowState.Added),true );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}
        
		try
		{
			BeginCase("HasChanges Deleted");
			Compare(ds.HasChanges(DataRowState.Deleted) ,true  );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}
		
		try
		{
			BeginCase("HasChanges Modified");
			Compare(ds.HasChanges(DataRowState.Modified),true);
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		try
		{
			BeginCase("HasChanges Unchanged");
			Compare(ds.HasChanges(DataRowState.Unchanged),true);
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}	
	}
开发者ID:nlhepler,项目名称:mono,代码行数:75,代码来源:DataSet_HasChanges_D.cs

示例15: CheckUnSavedChange

        /// <summary>
        /// ��ѯ�Ƿ��и���
        /// </summary>
        /// <param name="isQuery">
        /// �Ƿ��Dz�ѯ,true .�Dz�ѯʱ,����Ƿ��и���,
        ///            false �����Dz�ѯʱ,�������д���,����ʾ����</param>
        /// <param name="tBindSource"></param>
        public static void CheckUnSavedChange(bool isQuery, System.Windows.Forms.BindingSource tBindSource)
        {
            try
            {
                tBindSource.EndEdit();
                DataSet dsBindSet = new DataSet();
                if (tBindSource.DataSource is DataSet)
                {
                    dsBindSet = (DataSet)tBindSource.DataSource;
                }
                else if (tBindSource.DataSource is DataTable)
                {
                    DataTable dt = (DataTable)tBindSource.DataSource;
                    dsBindSet = dt.DataSet;
                }
                if (dsBindSet.HasChanges())
                {
                    throw new Exception("�����ѱ����ġ�");
                }
            }
            catch (Exception ex)
            {
                if (!isQuery)
                {
                    if (!ex.Message.Equals("�����ѱ����ġ�"))
                        throw new Exception(ex.Message);

                }
                DialogResult dr = EF.EFMessageBox.Show("��������ʧδ����ĸ��ģ��Ƿ������", "epEname", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dr == DialogResult.No)
                {
                    throw new Exception("�������.���������ĸ��ġ�");
                }
            }
        }
开发者ID:sunpander,项目名称:VSDT,代码行数:42,代码来源:Utility.cs


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