예제 #1
0
 private string SqlDeleteGarbageData(TwoColumnsTableDataAuto objTwoColumnsTableDataAuto)
 {
     try
     {
         string sqlForDelete = null;
         sqlForDelete = @"  DELETE FROM [TwoColumnsTableAuto] WHERE [TableID] = " + objTwoColumnsTableDataAuto.TableID + "; ";
         return(sqlForDelete);
     }
     catch (Exception msgException)
     {
         throw msgException;
     }
 }
예제 #2
0
 private void ApplyDefaultData(string lblTableID, string lblTableName)
 {
     try
     {
         _objTwoColumnsTableDataAuto           = new TwoColumnsTableDataAuto();
         _objTwoColumnsTableDataAuto.TableID   = Convert.ToInt32(lblTableID);
         _objTwoColumnsTableDataAuto.TableName = lblTableName;
         _objTwoColumnsTableDataAutoController = new TwoColumnsTableDataAutoController();
         _objTwoColumnsTableDataAutoController.Save(_connectionString, _objTwoColumnsTableDataAuto);
     }
     catch (Exception msgException)
     {
         throw msgException;
     }
 }
예제 #3
0
 private string SqlCreateView(TwoColumnsTableDataAuto objTwoColumnsTableDataAuto)
 {
     try
     {
         string sqlForView = null;
         sqlForView  = @" if exists(Select * from sysobjects where name = '" + objTwoColumnsTableDataAuto.TableName.Replace(" ", String.Empty) + "' and type = 'V' ) begin drop view " + objTwoColumnsTableDataAuto.TableName.Replace(" ", String.Empty) + " end;";
         sqlForView += " exec('create view " + objTwoColumnsTableDataAuto.TableName.Replace(" ", string.Empty) +
                       @" as SELECT [FieldOfID]
                           ,[FieldOfName]
                           ,[DataUsed]
                           ,[EntryUserID]
                           ,[EntryDate]
                           ,[LastUpdateDate]
                           ,[LastUpdateUserID]
                       FROM [TwoColumnsTableAuto] WHERE [TableID] = " + objTwoColumnsTableDataAuto.TableID + "');";
         return(sqlForView);
     }
     catch (Exception msgException)
     {
         throw msgException;
     }
 }
예제 #4
0
        public void Save(string connectionString, TwoColumnsTableDataAuto objTwoColumnsTableDataAuto)
        {
            try
            {
                DataTable dtDefaultData = new DataTable();
                var       storedProcedureComandTestTemp = "";
                storedProcedureComandTestTemp  = SqlCreateTable();
                storedProcedureComandTestTemp += SqlDeleteGarbageData(objTwoColumnsTableDataAuto);
                TwoColumnTables objTwoColumnTables = new TwoColumnTables();
                objTwoColumnTables.TableID = objTwoColumnsTableDataAuto.TableID;
                AutoTableData objAutoTableData = new AutoTableData(objTwoColumnTables);
                dtDefaultData = objAutoTableData.ControlTableID();
                foreach (DataRow dtRow in dtDefaultData.Rows)
                {
                    objTwoColumnsTableDataAuto.EieldOfID   = dtRow[0].ToString();
                    objTwoColumnsTableDataAuto.FieldOfName = dtRow[1].ToString();

                    var storedProcedureComandTest = "INSERT INTO [TwoColumnsTableAuto] ([TableID], [FieldOfID], [FieldOfName], [DataUsed], [EntryUserID], [EntryDate]) VALUES ( " +
                                                    objTwoColumnsTableDataAuto.TableID + ",'" +
                                                    objTwoColumnsTableDataAuto.EieldOfID + "', '" +
                                                    objTwoColumnsTableDataAuto.FieldOfName + "', '" +
                                                    "A" + "', '" +
                                                    "160ea939-7633-46a8-ae49-f661d12abfd5" + "'," +
                                                    "CAST(GETDATE() AS DateTime));";
                    storedProcedureComandTestTemp += storedProcedureComandTest;
                }

                storedProcedureComandTestTemp += SqlCreateView(objTwoColumnsTableDataAuto);

                clsDataManipulation.StoredProcedureExecuteNonQuery(connectionString, storedProcedureComandTestTemp);
            }
            catch (Exception msgException)
            {
                throw msgException;
            }
        }