private void saveToolStripButton_Click(object sender, EventArgs e) { // int index = xtraTabControl_MASTER_MNG_DETAY.SelectedTabPageIndex; for (int index = 0; index < xtraTabControl_MASTER_MNG_DETAY.TabPages.Count; index++) { if (index != -1) { var rtb = xtraTabControl_MASTER_MNG_DETAY.TabPages[index].Controls[0]; DevExpress.XtraGrid.GridControl grd_ = (DevExpress.XtraGrid.GridControl)rtb; System.Data.DataView RW = (System.Data.DataView)grd_.DataSource; SqlConnection con = new SqlConnection(_GLOBAL_PARAMETRELER._CONNECTION_STRING.ToString()); con.Open(); if (RW != null) { TARIFELER._GLOBAL_TARIFELER MAS = new TARIFELER._GLOBAL_TARIFELER(); // SATIR SİL RW.RowStateFilter = DataViewRowState.Deleted; if (RW.Count != 0) { int Counter = 0; string GUIS = ""; for (int i = 0; i <= RW.Count - 1; i++) { Counter++; DataRow DR = RW[i].Row; if (DR["ID", DataRowVersion.Original].ToString() != "") { GUIS += "'" + DR["ID", DataRowVersion.Original].ToString() + "',"; } if (Counter == 1000) { GUIS = GUIS.Substring(0, GUIS.Length - 1); SqlCommand Cmd = new SqlCommand() { CommandText = " DELETE [dbo].[__MAS_EDT_" + rtb.Tag.ToString() + "_" + rtb.Name + "] WHERE ID IN ( " + GUIS + " )" }; Cmd.CommandTimeout = 0; Cmd.Connection = con; Cmd.ExecuteNonQuery(); Counter = 0; GUIS = ""; } } if (GUIS.Length > 0) { GUIS = GUIS.Substring(0, GUIS.Length - 1); SqlCommand smd = new SqlCommand() { CommandText = " DELETE [dbo].[__MAS_EDT_" + rtb.Tag.ToString() + "_" + rtb.Name + "] WHERE ID IN ( " + GUIS + " )" }; smd.CommandTimeout = 0; smd.Connection = con; smd.ExecuteNonQuery(); } } // Yeni eklenmiş Satırları kaydet RW.RowStateFilter = DataViewRowState.Added; if (RW.Count != 0) { for (int i = 0; i <= RW.Count - 1; i++) { DataRow DR = RW[i].Row; MAS.MASTER_ROW_ADD(con, DR, rtb.Name, rtb.Tag.ToString()); } } // SATIR GUNCELLE RW.RowStateFilter = DataViewRowState.ModifiedOriginal; if (RW.Count != 0) { for (int i = 0; i <= RW.Count - 1; i++) { DataRow DR = RW[i].Row; MAS.MASTER_ROW_UPDATE(con, DR, rtb.Name, rtb.Tag.ToString()); } } RW.Table.AcceptChanges(); RW.RowStateFilter = DataViewRowState.CurrentRows; } } } }