コード例 #1
0
ファイル: Contractor.cs プロジェクト: lexxkrt/usno
        public bool Delete(Contractor contractor)
        {
            using (var command = new FbCommand())
            {
                command.Connection = ConnectionHelper.Connection;
                if (command.Connection.State != System.Data.ConnectionState.Open)
                    command.Connection.Open();

                command.CommandText = @"DELETE FROM CONTRACTORS WHERE ID=@ID";
                command.Parameters.AddWithValue("@ID", contractor.Id);
                try
                {
                    command.ExecuteNonQuery();
                    return true;
                }
                catch
                {
                    return false;
                }
            }
        }
コード例 #2
0
ファイル: Contractor.cs プロジェクト: lexxkrt/usno
        public Contractor Save(Contractor contractor)
        {
            using (var command = new FbCommand())
            {
                command.Connection = ConnectionHelper.Connection;
                if (command.Connection.State != System.Data.ConnectionState.Open)
                    command.Connection.Open();

                command.CommandText =
            @"UPDATE OR INSERT INTO CONTRACTORS(ID,NAME,ISNOTACTIVE)
            VALUES(@ID,@NAME,@ISNOTACTIVE)
            MATCHING(ID)
            RETURNING ID";
                command.Parameters.AddWithValue("@ID", contractor.Id);
                command.Parameters.AddWithValue("@NAME", contractor.Name);
                command.Parameters.AddWithValue("@ISNOTACTIVE", contractor.IsNotActive);
                contractor.Id = (int)command.ExecuteScalar();
                return contractor;
            }
        }