コード例 #1
0
ファイル: MatchManager.cs プロジェクト: bllr777/CheckWork
        public static int Save(Match matchToSave)
        {
            Match match = new Match();
            match.MatchId = matchToSave.MatchId;

            if (matchToSave.MatchId > 0)
                match.MatchId = matchToSave.MatchId;

            if (matchToSave.MatchValue != null)
                match.MatchValue = matchToSave.MatchValue;

            return MatchDAL.Save(matchToSave);
        }
コード例 #2
0
ファイル: MatchDAL.cs プロジェクト: bllr777/CheckWork
        public static int Save(Match matchToSave)
        {
            int result = 0;
            ExecuteTypeEnum queryId = ExecuteTypeEnum.InsertItem;

            // notes:       check for valid MatchId - if exists then UPDATE , else INSERT
            if (matchToSave.MatchId > 0)
                queryId = ExecuteTypeEnum.UpdateItem;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_ExecuteMatch", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@QueryId", queryId);
                    myCommand.Parameters.AddWithValue("@MatchId", matchToSave.MatchId);

                    if (matchToSave.MatchValue != null)
                        myCommand.Parameters.AddWithValue("@Match", matchToSave.MatchValue);
                  ;

                    //notes:    add return output parameter to command object
                    myCommand.Parameters.Add(HelperDAL.GetReturnParameterInt("ReturnValue"));

                    myConnection.Open();
                    myCommand.ExecuteNonQuery();

                    //notes:    get return value from stored procedure and return Id
                    result = (int)myCommand.Parameters["@ReturnValue"].Value;
                }
                myConnection.Close();
            }
            return result;
        }
コード例 #3
0
ファイル: MatchDAL.cs プロジェクト: bllr777/CheckWork
        private static Match FillDataRecord(IDataRecord myDataRecord)
        {
            Match myObject = new Match();

            myObject.MatchId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("MatchId"));

            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Match")))
                myObject.MatchValue = myDataRecord.GetString(myDataRecord.GetOrdinal("Match"));

            return myObject;
        }