コード例 #1
0
        public void UpdateExpensesInfo(ExpensesInfo expensesInfo, int CId)
        {
            SQLConn sQLConn = new SQLConn();
            string  query   = @"Update ExpensesInfo  set Amount = @Amount , EDescription = @EDescription ,
                             EDate = @EDate , DDate = @DDate
                              where ID= @CId";

            SqlCommand sqlCommand = new SqlCommand(query, sQLConn.GetConnToLocalDb());

            SqlParameter sqlParameter = new SqlParameter
            {
                ParameterName = "Amount",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = expensesInfo.EAmount
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "EDescription",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = expensesInfo.EDescription
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "EDate",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = expensesInfo.EDate
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "DDate",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = expensesInfo.DDate
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlCommand.ExecuteNonQuery();
            sqlParameter = new SqlParameter
            {
                ParameterName = "CId",
                SqlDbType     = System.Data.SqlDbType.Int,
                Value         = CId
            };

            sqlCommand.Parameters.Add(sqlParameter);
            sqlCommand.ExecuteNonQuery();
        }
コード例 #2
0
        public void InsertExpensesInfo(ExpensesInfo expensesInfo)
        {
            SQLConn    sQLConn    = new SQLConn();
            string     query      = @"insert into expensesinfo(@Amount , @EDescription , @EDate , @DDate)";
            SqlCommand sqlCommand = new SqlCommand(query, sQLConn.GetConnToLocalDb());

            SqlParameter sqlParameter = new SqlParameter
            {
                ParameterName = "Amount",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = expensesInfo.EAmount
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "EDescription",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = expensesInfo.EDescription
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "EDate",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = expensesInfo.EDate
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlParameter = new SqlParameter
            {
                ParameterName = "DDate",
                SqlDbType     = System.Data.SqlDbType.NVarChar,
                Value         = expensesInfo.DDate
            };

            sqlCommand.Parameters.Add(sqlParameter);

            sqlCommand.ExecuteNonQuery();
        }