當前位置: 首頁>>代碼示例>>C#>>正文


C# DataTable.RejectChanges方法代碼示例

本文整理匯總了C#中System.Data.DataTable.RejectChanges方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.RejectChanges方法的具體用法?C# DataTable.RejectChanges怎麽用?C# DataTable.RejectChanges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Data.DataTable的用法示例。


在下文中一共展示了DataTable.RejectChanges方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GrabarArticulosAgrupar

 public static void GrabarArticulosAgrupar(DataTable tblStock, DataTable tblArticulos, ref int? codigoError)
 {
     MySqlTransaction tr = null;
     try
     {
         MySqlConnection SqlConnection1 = DALBase.GetConnection();
         tr = SqlConnection1.BeginTransaction();
         DAL.ArticulosDAL.BorrarArticulosAgrupar(tblArticulos, SqlConnection1, tr);
         DAL.StockDAL.Update(tblStock, SqlConnection1, tr);
         tr.Commit();
         SqlConnection1.Close();
     }
     catch (MySqlException ex)
     {
         switch (ex.Number)
         {
             case 1042: //Unable to connect to any of the specified MySQL hosts.
                 tblStock.RejectChanges();
                 tblArticulos.RejectChanges();
                 codigoError = 1042;
                 break;
             case 0: // Procedure or function cannot be found in database
                 tblStock.RejectChanges();
                 tblArticulos.RejectChanges();
                 codigoError = ex.Number;
                 break;
             default:
                 tblStock.RejectChanges();
                 tblArticulos.RejectChanges();
                 if (tr != null)
                 {
                     tr.Rollback();
                 }
                 codigoError = ex.Number;
                 break;
         }
     }
     catch (TimeoutException)
     {
         codigoError = 8953; // El número 8953 lo asigné al azar
     }
     catch (NullReferenceException)
     {
         codigoError = 8954; // El número 8954 lo asigné al azar
     }
     catch (Exception)
     {
         codigoError = 8955; // El número 8955 lo asigné al azar
     }
 }
開發者ID:BenjaOtero,項目名稱:trend-gestion-desktop,代碼行數:50,代碼來源:TransaccionesBLL.cs

示例2: GrabarDB

 public static void GrabarDB(DataTable tblUsuarios)
 {
     try
     {
         DAL.ColoresDAL.GrabarDB(tblUsuarios);
     }
     catch (MySqlException ex)
     {
         MessageBox.Show(ex.ToString(), "NcSoft", MessageBoxButtons.OK, MessageBoxIcon.Information);
         tblUsuarios.RejectChanges();
     }
 }
開發者ID:BenjaOtero,項目名稱:trend-gestion-desktop,代碼行數:12,代碼來源:UsuariosBLL.cs

示例3: setModified_testRollback

		public void setModified_testRollback()
		{
			DataTable table = new DataTable();
			table.Columns.Add("col1", typeof(int));
			table.Columns.Add("col2", typeof(int));

			DataRow row = table.Rows.Add(new object[] { 1, 1 });
			table.AcceptChanges();

			row.SetModified ();
			Assert.AreEqual(row.RowState, DataRowState.Modified, "#0");
			Assert.AreEqual(1, row [0, DataRowVersion.Current], "#1");
			Assert.AreEqual(1, row [0, DataRowVersion.Original], "#2");
			table.RejectChanges ();
			Assert.AreEqual(row.RowState, DataRowState.Unchanged, "#3");
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:16,代碼來源:DataRowTest2.cs

示例4: setAdded_testRollback

		public void setAdded_testRollback ()
		{
			DataTable table = new DataTable ();
			table.Columns.Add ("col1", typeof (int));
			table.Columns.Add ("col2", typeof (int));

			table.Rows.Add (new object[] {1,1});
			table.AcceptChanges ();

			table.Rows [0].SetAdded ();
			table.RejectChanges ();
			Assert.AreEqual (0, table.Rows.Count, "#1");
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:13,代碼來源:DataRowTest2.cs

示例5: ActualizaBase

 private int ActualizaBase(DataTable conjuntoDeDatos)
 {
     try
     {
         if (conjuntoDeDatos == null) return -1;
         // Comprobar errores
         DataRow[] RenglonesMal = conjuntoDeDatos.GetErrors();
         // Si no hay errores se actualiza la base de
         // datos. En otro caso se avisa al usuario
         if (RenglonesMal.Length == 0)
         {
             int numeroDeRenglones = miAdaptador.Update(conjuntoDeDatos);
             conjuntoDeDatos.AcceptChanges();
             Error = "";
             misDatos = conjuntoDeDatos;
             return numeroDeRenglones;
         }
         else
         {
             Error = "";
             foreach (DataRow renglon in RenglonesMal)
             {
                 foreach (DataColumn columna in renglon.GetColumnsInError())
                 {
                     Error += renglon.GetColumnError(columna) + "\n";
                 }
             }
             conjuntoDeDatos.RejectChanges();
             misDatos = conjuntoDeDatos;
             return -1;
         }
     }
     catch (Exception ex)
     {
         Error = ex.Message;
         return -1;
     }
 }
開發者ID:pecesama,項目名稱:conexionOleDb,代碼行數:38,代碼來源:conexionOleDb.cs

示例6: Changes

		public void Changes () //To test GetChanges and RejectChanges
		{
			DataTable table = new DataTable ();

			DataColumn col = new DataColumn ();
			col.ColumnName = "Id";
			col.DataType = typeof (int);
			table.Columns.Add (col);
			UniqueConstraint uc = new UniqueConstraint ("UK1", table.Columns[0] );
			table.Constraints.Add (uc);

			col = new DataColumn ();
			col.ColumnName = "Name";
			col.DataType = typeof (string);
			table.Columns.Add (col);

			DataRow row = table.NewRow ();
			row ["Id"] = 147;
			row ["name"] = "Abc";
			table.Rows.Add (row);
			table.AcceptChanges ();

			row = table.NewRow ();
			row ["Id"] = 47;
			row ["name"] = "Efg";
			table.Rows.Add (row);

			//Testing GetChanges
			DataTable changesTable = table.GetChanges ();
			Assert.AreEqual (1, changesTable.Rows.Count, "#A01");
 			Assert.AreEqual ("Efg", changesTable.Rows[0]["Name"], "#A02");
			table.AcceptChanges ();
			changesTable = table.GetChanges ();

			try {
				int cnt = changesTable.Rows.Count;
				Assert.Fail ();
			} catch (NullReferenceException) {
			}
			
			//Testing RejectChanges
			row = table.NewRow ();
			row ["Id"] = 247;
			row ["name"] = "Hij";
			table.Rows.Add (row);

			(table.Rows [0])["Name"] = "AaBbCc";
			table.RejectChanges ();
			Assert.AreEqual ("Abc" , (table.Rows [0]) ["Name"], "#A03");
			Assert.AreEqual (2, table.Rows.Count, "#A04");
		}
開發者ID:symform,項目名稱:mono,代碼行數:51,代碼來源:DataTableTest.cs

示例7: GetLockRow

        private DataRow GetLockRow(DataTable tbl)
        {
            DataRow row = tbl.Rows.Find(m_Values);
            if (row == null)
            {
                try
                {
                    DataRow newrow = tbl.NewRow();
                    newrow.BeginEdit();

                    newrow["tablename"] = m_strTableName;
                    newrow["fieldnames"] = m_strKeys;
                    newrow["fieldvalues"] = m_strValues;
                    newrow["lastversion"] = 0;
                    newrow["modid"] = DBNull.Value;

                    newrow["lockip"] = DBNull.Value;
                    newrow["lockhostname"] = DBNull.Value;
                    newrow["lockusername"] = DBNull.Value;

                    newrow["locktime"] = DBNull.Value;// DateTime.MinValue;
                    newrow["unlocktime"] = DBNull.Value;//DateTime.MinValue;

                    newrow.EndEdit();
                    tbl.Rows.Add(newrow);

                    SqlCommandBuilder cmdBuilder = m_cmdBuilder;// new SqlCommandBuilder(m_adp);
                    m_adp.InsertCommand = cmdBuilder.GetInsertCommand();
                    int val = m_adp.Update(tbl);
                    tbl.AcceptChanges();
                    row = newrow;
                }
                catch (Exception ex)
                {
                    tbl.RejectChanges();
                    throw ex;
                }
            }
            return row;
        }
開發者ID:viticm,項目名稱:pap2,代碼行數:40,代碼來源:RecordLock.cs

示例8: LoadRowTestPreserveChanges

		public void LoadRowTestPreserveChanges ()
		{
			DataTable dt = new DataTable ();
			dt.Columns.Add ("id", typeof (int));
			dt.Columns.Add ("name", typeof (string));

			dt.Rows.Add (new object [] { 1, "mono 1" });
			dt.Rows.Add (new object [] { 2, "mono 2" });
			dt.Rows.Add (new object [] { 3, "mono 3" });

			dt.PrimaryKey = new DataColumn [] { dt.Columns ["id"] };
			dt.AcceptChanges ();
			try {
				SubscribeEvents (dt);

				// current - modified; new - modified
				ResetEventFlags ();
				dt.LoadDataRow (new object [] { 2, "mono test" }, LoadOption.PreserveChanges);
				Assert.AreEqual (3, dt.Rows.Count, "#1 should not add a new row");
				Assert.AreEqual ("mono test", dt.Rows [1] [1], "#2 should change the current");
				Assert.AreEqual ("mono test", dt.Rows [1] [1, DataRowVersion.Original], "#3 should change the original");
				Assert.AreEqual (DataRowState.Unchanged, dt.Rows [1].RowState, "#4 has not changed the row state");
				Assert.IsTrue (rowChanging, "#ltpc11 row changing not called");
				Assert.AreEqual (dt.Rows [1], rowInAction_Changing, "#ltpc12 this row is not intended to change");
				Assert.AreEqual (DataRowAction.ChangeCurrentAndOriginal, rowAction_Changing, "#ltpc13 row action is not Change");
				Assert.IsTrue (rowChanged, "#ltpc14 row changed not called");
				Assert.AreEqual (dt.Rows [1], rowInAction_Changed, "#ltpc15 this row is not intended to change");
				Assert.AreEqual (DataRowAction.ChangeCurrentAndOriginal, rowAction_Changed, "#ltpc16 row action is not Change");

				// current - none; new - unchanged
				ResetEventFlags ();
				dt.LoadDataRow (new object [] { 4, "mono 4" }, LoadOption.PreserveChanges);
				Assert.AreEqual (4, dt.Rows.Count,"#5 should add a new row");
				Assert.AreEqual ("mono 4", dt.Rows [3] [1], "#6 should change the current");
				Assert.AreEqual ("mono 4", dt.Rows [3] [1, DataRowVersion.Original], "#7 should change the original");
				Assert.AreEqual (DataRowState.Unchanged, dt.Rows [3].RowState, "#8 has not changed the row state");
				Assert.IsTrue (rowChanging, "#ltpc21 row changing not called");
				Assert.AreEqual (dt.Rows [3], rowInAction_Changing, "#ltpc22 this row is not intended to change");
				Assert.AreEqual (DataRowAction.ChangeCurrentAndOriginal, rowAction_Changing, "#ltpc23 row action is not Change");
				Assert.IsTrue (rowChanged, "#ltpc24 row changed not called");
				Assert.AreEqual (dt.Rows [3], rowInAction_Changed, "#ltpc25 this row is not intended to change");
				Assert.AreEqual (DataRowAction.ChangeCurrentAndOriginal, rowAction_Changed, "#ltpc16 row action is not Change");


				dt.RejectChanges ();
                
				// current - added; new - modified
				dt.Rows.Add (new object [] { 5, "mono 5" });
				ResetEventFlags ();
				dt.LoadDataRow (new object [] { 5, "mono test" }, LoadOption.PreserveChanges);
				Assert.AreEqual (5, dt.Rows.Count, "#9 should not add a new row");
				Assert.AreEqual ("mono 5", dt.Rows [4] [1], "#10 should not change the current");
				Assert.AreEqual ("mono test", dt.Rows [4] [1, DataRowVersion.Original], "#11 should change the original");
				Assert.AreEqual (DataRowState.Modified, dt.Rows [4].RowState, "#12 has not changed the row state");
				Assert.IsTrue (rowChanging, "#ltpc31 row changing not called");
				Assert.AreEqual (dt.Rows [4], rowInAction_Changing, "#ltpc32 this row is not intended to change");
				Assert.AreEqual (DataRowAction.ChangeOriginal, rowAction_Changing, "#ltpc33 row action is not Change");
				Assert.IsTrue (rowChanged, "#ltpc34 row changed not called");
				Assert.AreEqual (dt.Rows [4], rowInAction_Changed, "#ltpc35 this row is not intended to change");
				Assert.AreEqual (DataRowAction.ChangeOriginal, rowAction_Changed, "#ltpc36 row action is not Change");


				dt.RejectChanges ();

				// current - deleted ; new - deleted ChangeOriginal
				ResetEventFlags ();
				dt.Rows [1].Delete ();
				Assert.IsTrue (rowDeleting, "#ltpc37 row deleting");
				Assert.IsTrue (rowDeleted, "#ltpc38 row deleted");
				Assert.AreEqual (rowInAction_Deleting, dt.Rows[1], "#ltpc39 rowInAction_Deleting");
				Assert.AreEqual (rowInAction_Deleted, dt.Rows[1], "#ltpc40 rowInAction_Deleted");
				Assert.AreEqual (rowAction_Deleting, DataRowAction.Delete, "#ltpc60 rowInAction_Deleting");
				Assert.AreEqual (rowAction_Deleted, DataRowAction.Delete, "#ltpc61 rowInAction_Deleted");
				dt.LoadDataRow (new object [] { 2, "mono deleted" }, LoadOption.PreserveChanges);
				Assert.AreEqual (5, dt.Rows.Count, "#13 should not add a new row");
				Assert.AreEqual ("mono deleted", dt.Rows [1] [1, DataRowVersion.Original], "#14 should change the original");
				Assert.AreEqual (DataRowState.Deleted, dt.Rows [1].RowState, "#15 has not changed the row state");
				Assert.IsTrue (rowChanging, "#ltpc41 row changing not called");
				Assert.AreEqual (dt.Rows [1], rowInAction_Changing, "#ltpc42 this row is not intended to change");
				Assert.AreEqual (DataRowAction.ChangeOriginal, rowAction_Changing, "#ltoc43 row action is not Change");
				Assert.IsTrue (rowChanged, "#ltpc44 row changed not called");
				Assert.AreEqual (dt.Rows [1], rowInAction_Changed, "#ltpc45 this row is not intended to change");
				Assert.AreEqual (DataRowAction.ChangeOriginal, rowAction_Changed, "#ltpc46 row action is not Change");


			} finally {
				UnsubscribeEvents (dt);
			}
		}
開發者ID:shana,項目名稱:mono,代碼行數:89,代碼來源:DataTableLoadRowTest.cs

示例9: _Update

 /// <summary>
 /// private Methode zum Update der Datenbankdatei!
 /// </summary>
 /// <param name="adapter"></param>
 /// <param name="tabelle"></param>
 private void _Update(OleDbDataAdapter adapter, DataTable tabelle)
 {
     try
     {
         // Änderungen im Spiegel für die Festplattendatenbank übernehmen
         adapter.Update(tabelle);
         // Änderungen als übernommen markieren
         tabelle.AcceptChanges();
     }
     catch (Exception)
     {
         // Sollte ein Fehler auftreten, werden die Änderungen im Spiegel verworfen.
         tabelle.RejectChanges();
         throw new Exception("Änderungen an der Datenbank konnte nicht durchgeführt werden!");
     }
 }
開發者ID:julianaym,項目名稱:Prog2Homework,代碼行數:21,代碼來源:Kundenverzeichnis.cs

示例10: LoadRowTestUpsert

                public void LoadRowTestUpsert ()
                {
                        DataTable dt = new DataTable ();
                        dt.Columns.Add ("id", typeof (int));
                        dt.Columns.Add ("name", typeof (string));

                        dt.Rows.Add (new object [] { 1, "mono 1" });
                        dt.Rows.Add (new object [] { 2, "mono 2" });
                        dt.Rows.Add (new object [] { 3, "mono 3" });

                        dt.PrimaryKey = new DataColumn [] { dt.Columns ["id"] };

                        dt.AcceptChanges ();

                        dt.LoadDataRow (new object [] { 2, "mono test" }, LoadOption.Upsert);
                        Assert.AreEqual (3, dt.Rows.Count, "#1 should not add a row");
                        Assert.AreEqual ("mono test", dt.Rows [1] [1], "#2 should change the current");
                        Assert.AreEqual ("mono 2", dt.Rows [1] [1, DataRowVersion.Original], "#3 should not change original");
                        Assert.AreEqual (DataRowState.Modified, dt.Rows [1].RowState, "#4 should change state");


                        // Row State tests
                        // current - modified ; result - modified
                        dt.LoadDataRow (new object [] { 2, "mono test 2" }, LoadOption.Upsert);
                        Assert.AreEqual ("mono test 2", dt.Rows [1] [1], "#c1 should change the current");
                        Assert.AreEqual ("mono 2", dt.Rows [1] [1, DataRowVersion.Original], "#c2 should not change original");
                        Assert.AreEqual (DataRowState.Modified, dt.Rows [1].RowState, "#c3 should not change state");

                        // current - Unchanged; result - Unchanged if no new value
                        dt.AcceptChanges ();
                        dt.LoadDataRow (new object [] { 2, "mono test 2" }, LoadOption.Upsert);
                        Assert.AreEqual ("mono test 2", dt.Rows [1] [1], "#c4 should change the current");
                        Assert.AreEqual ("mono test 2", dt.Rows [1] [1, DataRowVersion.Original], "#c5 should not change original");
                        Assert.AreEqual (DataRowState.Unchanged, dt.Rows [1].RowState, "#c6 should not change state");
                        // not the same value again
                        dt.RejectChanges ();
                        dt.LoadDataRow (new object [] { 2, "mono test 3" }, LoadOption.Upsert);
                        Assert.AreEqual (DataRowState.Modified, dt.Rows [1].RowState, "#c7 should not change state");

                        // current - added; result - added
                        dt.Rows.Add (new object [] { 4, "mono 4" });
                        dt.LoadDataRow (new object [] { 4, "mono 4" }, LoadOption.Upsert);
                        Assert.AreEqual ("mono 4", dt.Rows [3] [1], "#c8 should change the current");
                        try {
                                object o = dt.Rows [3] [1, DataRowVersion.Original];
                                Assert.Fail ("#c9 should have thrown version not found exception");
                        } catch (VersionNotFoundException) { }
                        Assert.AreEqual (DataRowState.Added, dt.Rows [3].RowState, "#c10 should not change state");

                        // current - new; result - added
                        dt.LoadDataRow (new object [] { 5, "mono 5" }, LoadOption.Upsert);
                        Assert.AreEqual ("mono 5", dt.Rows [4] [1], "#c11 should change the current");
                        try {
                                object o = dt.Rows [4] [1, DataRowVersion.Original];
                                Assert.Fail ("#c12 should have thrown version not found exception");
                        } catch (VersionNotFoundException) { }
                        Assert.AreEqual (DataRowState.Added, dt.Rows [4].RowState, "#c13 should change state");

                        // current - deleted; result - added a new row
                        dt.AcceptChanges ();
                        dt.Rows [4].Delete ();
                        dt.LoadDataRow (new object [] { 5, "mono 5" }, LoadOption.Upsert);
                        Assert.AreEqual (6, dt.Rows.Count, "#c14 should not add a row");
                        Assert.AreEqual ("mono 5", dt.Rows [5] [1], "#c15 should change the current");
                        try {
                                object o = dt.Rows [5] [1, DataRowVersion.Original];
                                Assert.Fail ("#c16 expected version not found exception ");
                        } catch (VersionNotFoundException) {}
                        Assert.AreEqual (DataRowState.Added, dt.Rows [5].RowState, "#c17 should change state");
                }
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:70,代碼來源:DataTableLoadRowTest.cs

示例11: UpdateRow

        private bool UpdateRow(DataTable tbl, DataRow row, int nLastVer, DateTime dtLock, DateTime dtUnLock, bool bLock)
        {
            try
            {
                row.BeginEdit();

                row["tablename"] = m_strTableName;
                row["lastversion"] = nLastVer;

                if (bLock)
                {
                    row["lockip"] = m_strIP;
                    row["lockhostname"] = m_strHostName;
                    row["lockusername"] = m_strHostName;

                    if (dtLock == DateTime.MinValue)
                        row["locktime"] = DBNull.Value;
                    else
                        row["locktime"] = dtLock;

                    if (dtUnLock == DateTime.MinValue)
                        row["unlocktime"] = DBNull.Value;
                    else
                        row["unlocktime"] = dtUnLock;
                }
                else
                {
                    row["lockip"] = DBNull.Value;
                    row["lockhostname"] = DBNull.Value;
                    row["lockusername"] = DBNull.Value;

                    row["locktime"] = DBNull.Value;
                    if (dtUnLock == DateTime.MinValue)
                        row["unlocktime"] = DBNull.Value;
                    else
                        row["unlocktime"] = dtUnLock;
                }

                row.EndEdit();

                SqlCommandBuilder cmdBuilder = m_cmdBuilder;// new SqlCommandBuilder(m_adp);
                m_adp.UpdateCommand = cmdBuilder.GetUpdateCommand();
                int val = m_adp.Update(tbl);
                tbl.AcceptChanges();
                return val > 0;
            }
            catch (Exception ex)
            {
                tbl.RejectChanges();
                MessageBox.Show(ex.Message);
                throw ex;
            }
        }
開發者ID:viticm,項目名稱:pap2,代碼行數:53,代碼來源:Lock.cs

示例12: UpdateRow

        private bool UpdateRow(DataTable tbl, DataRow row, int nLastVer, DateTime dtLock, DateTime dtUnLock, bool bLock)
        {
            int val = 0;

            try
            {
                if (bLock)
                {
                    row.BeginEdit();

                    row["fieldid"] = m_nFieldID;
                    row["modtabID"] = m_nModTabID;
                    row["tablename"] = m_strTableName;
                    row["fieldname"] = m_strFieldName;
                    row["lastversion"] = nLastVer;
               
                    row["lockip"] = m_strIP;
                    row["lockhostname"] = m_strHostName;
                    row["lockusername"] = m_strHostName;

                    if (dtLock == DateTime.MinValue)
                        row["locktime"] = DBNull.Value;
                    else
                        row["locktime"] = dtLock;

                    if (dtUnLock == DateTime.MinValue)
                        row["unlocktime"] = DBNull.Value;
                    else
                        row["unlocktime"] = dtUnLock;
                    row.EndEdit();
                }
                else
                {
                    row.Delete();
                }
                
                SqlCommandBuilder cmdBuilder = m_cmdBuilder;// new SqlCommandBuilder(m_adp);
                m_adp.UpdateCommand = cmdBuilder.GetUpdateCommand();
                val = m_adp.Update(tbl);

                tbl.AcceptChanges();
                return val > 0;
            }
            catch (Exception ex)
            {
                tbl.RejectChanges();
                throw ex;
            }
        }
開發者ID:viticm,項目名稱:pap2,代碼行數:49,代碼來源:ScriptLock.cs

示例13: btn_Undo_Click

 private void btn_Undo_Click(object sender, EventArgs e)
 {
     DataTable dt = new DataTable();
     dt.RejectChanges();
 }
開發者ID:DevKoala,項目名稱:Course-work,代碼行數:5,代碼來源:MainForm.cs

示例14: RejectChanges_CheckIndex

		public void RejectChanges_CheckIndex ()
		{
			DataTable table = new DataTable ();
			table.Columns.Add ("col1", typeof (int));
			table.PrimaryKey = new DataColumn[] {table.Columns [0]};

			table.Rows.Add (new object[] {1});
			table.AcceptChanges ();

			table.Rows [0][0] = 10;
			table.RejectChanges ();

			Assert.IsNotNull (table.Rows.Find (1));
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:14,代碼來源:DataTableTest2.cs

示例15: RemoveSelectRows

            /// <summary>
            /// 條件に當てはまるレコードをDataTableから削除します。
            /// </summary>
            /// <param name="dt">データテーブル</param>
            /// <param name="filter">條件</param>
            /// <returns>0:正常終了 -1:異常終了</returns>
            public static int RemoveSelectRows(DataTable dt, string filter)
            {
                try
                {
                    DataRow[] rows = dt.Select(filter);

                    for (int i = 0; i < rows.Length; i++)
                    {
                        if (rows[i].RowState != DataRowState.Deleted)
                        {
                            rows[i].Delete();
                        }
                    }
                    dt.AcceptChanges();
                    return 0;
                }
                catch (Exception)
                {
                    dt.RejectChanges();
                    return -1;
                }
            }
開發者ID:tokunaga-nakamura,項目名稱:tsssystem2,代碼行數:28,代碼來源:frm_seisan_koutei_m.cs


注:本文中的System.Data.DataTable.RejectChanges方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。